epoc32/include/stdapis/stlportv5/new
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
     1 /*
     2  * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(- *   * ies).
     3  * All rights reserved.
     4  * This component and the accompanying materials are made available
     5  * under the terms of the License "Eclipse Public License v1.0"
     6  * which accompanies this distribution, and is available
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     8  *
     9  * Initial Contributors:
    10  * Nokia Corporation - initial contribution.
    11  *
    12  * Contributors:
    13  *
    14  * Description:
    15  * Name       : new
    16  * Part of    : standard c++ library.
    17  *
    18  */
    19 
    20 
    21 #ifndef _SYMCPP_NEW_H_
    22 #define _SYMCPP_NEW_H_
    23 
    24 
    25 #ifndef _STLP_FEATURES_H
    26 #  include <stl/config/features.h>
    27 #endif
    28 
    29 
    30 
    31 # ifdef __EABI__
    32 #  include <stl/_cstddef.h> //Include the STLP internal header to make macros/typedefs expected of <csddef> available.
    33 #  define _STLP_CSTDDEF		//Define this macro so that <cstddef> doesn't get included by new_eabi.h
    34 
    35 #include "exception"
    36 
    37 namespace std
    38 {
    39 	typedef unsigned size_t;
    40 
    41 	class bad_alloc : public exception
    42 		{
    43 	public:
    44 		IMPORT_C bad_alloc() __NO_THROW;
    45 		IMPORT_C bad_alloc(const bad_alloc&) __NO_THROW;
    46 		IMPORT_C bad_alloc& operator=(const bad_alloc&) __NO_THROW;  // { return *this;}
    47 
    48 		IMPORT_C virtual ~bad_alloc() __NO_THROW;  // {}
    49 		IMPORT_C virtual const char* what() const __NO_THROW; //  { return "bad_alloc";}
    50 		};
    51 	
    52 	struct nothrow_t {};
    53 	extern const nothrow_t nothrow;
    54 
    55 	typedef void (*new_handler)();
    56 
    57 	IMPORT_C new_handler set_new_handler(new_handler) __NO_THROW;
    58 }
    59 
    60 // Single-object form
    61 
    62 IMPORT_C void* operator new(std::size_t) __THROW(std::bad_alloc);
    63 IMPORT_C void  operator delete(void*) __NO_THROW;
    64 
    65 IMPORT_C void* operator new(std::size_t, const std::nothrow_t&) __NO_THROW;
    66 IMPORT_C void  operator delete(void*, const std::nothrow_t&) __NO_THROW;
    67 
    68 #ifndef __PLACEMENT_NEW_INLINE
    69 	#define __PLACEMENT_NEW_INLINE
    70 	inline void* operator new(std::size_t, void* p) __NO_THROW
    71 		{
    72 		return p;
    73 		}
    74 
    75 	inline void operator delete(void*, void*) __NO_THROW
    76 		{
    77 		}
    78 #endif
    79 
    80 // Array form
    81 
    82 IMPORT_C void* operator new[](std::size_t) __THROW(std::bad_alloc);
    83 IMPORT_C void  operator delete[](void*) __NO_THROW;
    84 
    85 IMPORT_C void* operator new[](std::size_t, const std::nothrow_t&) __NO_THROW;
    86 IMPORT_C void  operator delete[](void*, const std::nothrow_t&) __NO_THROW;
    87 
    88 #ifndef __PLACEMENT_VEC_NEW_INLINE
    89 	#define __PLACEMENT_VEC_NEW_INLINE 
    90 	inline void* operator new[](std::size_t, void* p) __NO_THROW
    91 		{
    92 		return p;
    93 		}
    94 
    95 	inline void operator delete[](void*, void*) __NO_THROW
    96 		{
    97 		}
    98 #endif
    99 
   100 // Symbian additions (not part of standard C++).
   101 IMPORT_C void* operator new(std::size_t, std::size_t) __NO_THROW;
   102 IMPORT_C void  operator delete(void*, std::size_t) __NO_THROW;
   103 
   104 
   105 
   106 
   107 
   108 # else
   109 #  include <exception>
   110 #  include <stl/_cstddef.h>
   111 #  include <e32def.h>
   112 namespace std {
   113 
   114 	struct nothrow_t { };
   115 	extern const nothrow_t nothrow;
   116 
   117 	class bad_alloc : public exception {
   118 	public :
   119 		bad_alloc () __NO_THROW {};
   120 		bad_alloc ( const bad_alloc &) __NO_THROW {};
   121 		bad_alloc & operator =( const bad_alloc &) __NO_THROW { return *this;}
   122 		virtual const char * what () const __NO_THROW { return "bad_alloc";}
   123 	};
   124 
   125 	typedef void (* new_handler )();
   126 	new_handler set_new_handler ( new_handler new_p ) __NO_THROW;
   127 }
   128 
   129 IMPORT_C void* operator new    (std::size_t) __THROW(std::bad_alloc);
   130 IMPORT_C void  operator delete (void*)       __NO_THROW;
   131 
   132 IMPORT_C void* operator new    (std::size_t, const std::nothrow_t&) __NO_THROW;
   133 IMPORT_C void  operator delete (void*, const std::nothrow_t&)       __NO_THROW;
   134 
   135 IMPORT_C void* operator new[]    (std::size_t) __THROW(std::bad_alloc);
   136 IMPORT_C void  operator delete[] (void*)       __NO_THROW;
   137 
   138 IMPORT_C void* operator new[]    (std::size_t, const std::nothrow_t&) __NO_THROW;
   139 IMPORT_C void  operator delete[] (void*, const std::nothrow_t&)       __NO_THROW;
   140 
   141 #   ifndef __PLACEMENT_NEW_INLINE
   142 #   define __PLACEMENT_NEW_INLINE
   143 inline void* operator new(std::size_t, void* aBase) __NO_THROW
   144 	{return aBase;}
   145 
   146 inline void operator delete(void*,  void*)  __NO_THROW	{} 
   147 #   endif //__PLACEMENT_NEW_INLINE
   148 
   149 #   ifndef __PLACEMENT_VEC_NEW_INLINE
   150 #   define __PLACEMENT_VEC_NEW_INLINE
   151 inline void* operator new[](std::size_t, void* aBase)  __NO_THROW
   152 	{return aBase;}
   153 
   154 inline void operator delete[](void* , void*)  __NO_THROW {}
   155 #   endif //__PLACEMENT_VEC_NEW_INLINE
   156 
   157 # endif //__EABI__
   158 #endif //_SYMCPP_NEW_H_