Loading...
Searching...
No Matches
std_alloc
// vi:set ft=cpp: -*- Mode: C++ -*-
/*
* (c) 2008-2009 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
* Alexander Warg <warg@os.inf.tu-dresden.de>
* economic rights: Technische Universität Dresden (Germany)
*
* License: see LICENSE.spdx (in this directory or the directories above)
*/
#pragma once
#include <stddef.h>
namespace cxx {
class Nothrow {};
}
inline void *operator new (size_t, void *mem, cxx::Nothrow const &) noexcept
{ return mem; }
void *operator new (size_t, cxx::Nothrow const &) noexcept;
void operator delete (void *, cxx::Nothrow const &) noexcept;
namespace cxx {
template< typename _Type >
class New_allocator
{
public:
enum { can_free = true };
New_allocator() noexcept {}
New_allocator(New_allocator const &) noexcept {}
~New_allocator() noexcept {}
_Type *alloc() noexcept
{ return static_cast<_Type*>(::operator new(sizeof (_Type), cxx::Nothrow())); }
void free(_Type *t) noexcept
{ ::operator delete(t, cxx::Nothrow()); }
};
}
cxx::Nothrow
Helper type to distinguish the operator new version that does not throw exceptions.
Definition std_alloc:19
cxx
Our C++ library.
Definition arith:11