blob: 9d7ed45ee6703fd0f8fd1324d2d3250d1abbb9d6 [file] [log] [blame]
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001// -*- C++ -*-
2//===----------------------------- new ------------------------------------===//
3//
4// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
5//
6// This file is distributed under the University of Illinois Open Source
7// License. See LICENSE.TXT for details.
8//
9//===----------------------------------------------------------------------===//
10
11#ifndef _LIBCPP_NEW
12#define _LIBCPP_NEW
13
14/*
15 new synopsis
16
17namespace std
18{
19
20class bad_alloc
21 : public exception
22{
23public:
24 bad_alloc() throw();
25 bad_alloc(const bad_alloc&) throw();
26 bad_alloc& operator=(const bad_alloc&) throw();
27 virtual ~bad_alloc() throw();
28 virtual const char* what() const throw();
29};
30
31struct nothrow_t {};
32extern const nothrow_t nothrow;
33typedef void (*new_handler)();
34new_handler set_new_handler(new_handler new_p) throw();
35
36} // std
37
38void* operator new(std::size_t size) throw(std::bad_alloc); // replaceable
39void* operator new(std::size_t size, const std::nothrow_t&) throw(); // replaceable
40void operator delete(void* ptr) throw(); // replaceable
41void operator delete(void* ptr, const std::nothrow_t&) throw(); // replaceable
42
43void* operator new[](std::size_t size) throw(std::bad_alloc); // replaceable
44void* operator new[](std::size_t size, const std::nothrow_t&) throw(); // replaceable
45void operator delete[](void* ptr) throw(); // replaceable
46void operator delete[](void* ptr, const std::nothrow_t&) throw(); // replaceable
47
48void* operator new (std::size_t size, void* ptr) throw();
49void* operator new[](std::size_t size, void* ptr) throw();
50void operator delete (void* ptr, void*) throw();
51void operator delete[](void* ptr, void*) throw();
52
53*/
54
55#include <__config>
56#include <exception>
57#include <cstddef>
58
59#pragma GCC system_header
60
61namespace std // purposefully not using versioning namespace
62{
63
64class _LIBCPP_EXCEPTION_ABI bad_alloc
65 : public exception
66{
67public:
68 _LIBCPP_INLINE_VISIBILITY bad_alloc() throw() {}
69 virtual ~bad_alloc() throw();
70 virtual const char* what() const throw();
71};
72
73class _LIBCPP_EXCEPTION_ABI bad_array_new_length
74 : public bad_alloc
75{
76public:
77 _LIBCPP_INLINE_VISIBILITY bad_array_new_length() throw() {}
78 virtual ~bad_array_new_length() throw();
79 virtual const char* what() const throw();
80};
81
82void __throw_bad_alloc();
83
84struct nothrow_t {};
85extern _LIBCPP_VISIBLE const nothrow_t nothrow;
86typedef void (*new_handler)();
87_LIBCPP_VISIBLE new_handler set_new_handler(new_handler) throw();
88
89} // std
90
91_LIBCPP_VISIBLE void* operator new(std::size_t) throw(std::bad_alloc);
92_LIBCPP_VISIBLE void* operator new(std::size_t, const std::nothrow_t&) throw();
93_LIBCPP_VISIBLE void operator delete(void*) throw();
94_LIBCPP_VISIBLE void operator delete(void*, const std::nothrow_t&) throw();
95
96_LIBCPP_VISIBLE void* operator new[](std::size_t) throw(std::bad_alloc);
97_LIBCPP_VISIBLE void* operator new[](std::size_t, const std::nothrow_t&) throw();
98_LIBCPP_VISIBLE void operator delete[](void*) throw();
99_LIBCPP_VISIBLE void operator delete[](void*, const std::nothrow_t&) throw();
100
101_LIBCPP_INLINE_VISIBILITY inline void* operator new (std::size_t, void* __p) throw() {return __p;}
102_LIBCPP_INLINE_VISIBILITY inline void* operator new[](std::size_t, void* __p) throw() {return __p;}
103_LIBCPP_INLINE_VISIBILITY inline void operator delete (void*, void*) throw() {}
104_LIBCPP_INLINE_VISIBILITY inline void operator delete[](void*, void*) throw() {}
105
106#endif // _LIBCPP_NEW