L4Re Operating System Framework
Interface and Usage Documentation
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
std_alloc
1// vi:set ft=cpp: -*- Mode: C++ -*-
2/*
3 * (c) 2008-2009 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
4 * Alexander Warg <warg@os.inf.tu-dresden.de>
5 * economic rights: Technische Universität Dresden (Germany)
6 *
7 * License: see LICENSE.spdx (in this directory or the directories above)
8 */
9
10#pragma once
11
12#include <stddef.h>
13namespace cxx {
19class Nothrow {};
20}
21
28inline void *operator new (size_t, void *mem, cxx::Nothrow const &) noexcept
29{ return mem; }
30
35void *operator new (size_t, cxx::Nothrow const &) noexcept;
36
42void operator delete (void *, cxx::Nothrow const &) noexcept;
43
44namespace cxx {
45
46
55template< typename _Type >
57{
58public:
59 enum { can_free = true };
60
61 New_allocator() noexcept {}
62 New_allocator(New_allocator const &) noexcept {}
63
64 ~New_allocator() noexcept {}
65
66 _Type *alloc() noexcept
67 { return static_cast<_Type*>(::operator new(sizeof (_Type), cxx::Nothrow())); }
68
69 void free(_Type *t) noexcept
70 { ::operator delete(t, cxx::Nothrow()); }
71};
72
73}
74
Standard allocator based on operator new () .
Definition std_alloc:57
Helper type to distinguish the operator new version that does not throw exceptions.
Definition std_alloc:19
Our C++ library.
Definition arith:11