// new standard header for Microsoft #pragma once #ifndef _NEW_ #define _NEW_ #include #pragma pack(push,8) #pragma warning(push,3) _STD_BEGIN // CLASS bad_alloc class bad_alloc : public exception { // base of all bad allocation exceptions public: bad_alloc(const char *_Message = _MESG("bad allocation")) _THROW0() : exception(_Message) { // construct from message string } virtual ~bad_alloc() _THROW0() { // destroy the object } #if !_HAS_EXCEPTIONS protected: virtual void _Doraise() const { // perform class-specific exception handling _RAISE(*this); } #endif /* _HAS_EXCEPTIONS */ }; // SUPPORT TYPES #if !defined(_INC_NEW) || !defined(_MSC_EXTENSIONS) typedef void (__cdecl *new_handler)(); // handler for operator new failures #endif struct nothrow_t { // placement new tag type to suppress exceptions }; extern _CRTIMP2 const nothrow_t nothrow; // constant for placement new tag // FUNCTION AND OBJECT DECLARATIONS _CRTIMP2 new_handler __cdecl set_new_handler(new_handler) _THROW0(); // establish alternate new handler _STD_END // new AND delete DECLARATIONS (NB: NOT IN std) void __cdecl operator delete(void *) _THROW0(); void *__cdecl operator new(size_t) _THROW1(std::bad_alloc); void *__cdecl operator new(size_t, const std::nothrow_t&) _THROW0(); #ifndef __PLACEMENT_NEW_INLINE #define __PLACEMENT_NEW_INLINE inline void *__cdecl operator new(size_t, void *_Where) _THROW0() { // construct array with placement at _Where return (_Where); } inline void __cdecl operator delete(void *, void *) _THROW0() { // delete if placement new fails } #endif /* __PLACEMENT_NEW_INLINE */ #ifndef __PLACEMENT_VEC_NEW_INLINE #define __PLACEMENT_VEC_NEW_INLINE inline void *__cdecl operator new[](size_t, void *_Where) _THROW0() { // construct array with placement at _Where return (_Where); } inline void __cdecl operator delete[](void *, void *) _THROW0() { // delete if placement array new fails } #endif /* __PLACEMENT_VEC_NEW_INLINE */ void __cdecl operator delete[](void *) _THROW0(); // delete allocated array void *__cdecl operator new[](size_t) _THROW1(std::bad_alloc); // allocate array or throw exception void *__cdecl operator new[](size_t, const std::nothrow_t&) _THROW0(); // allocate array or return null pointer void __cdecl operator delete(void *, const std::nothrow_t&) _THROW0(); // delete if nothrow new fails -- REPLACEABLE void __cdecl operator delete[](void *, const std::nothrow_t&) _THROW0(); // delete if nothrow array new fails -- REPLACEABLE #if !defined(_INC_NEW) || !defined(_MSC_EXTENSIONS) using std::new_handler; #endif #pragma warning(pop) #pragma pack(pop) #endif /* _NEW_ */ /* * Copyright (c) 1992-2001 by P.J. Plauger. ALL RIGHTS RESERVED. * Consult your license regarding permissions and restrictions. V3.10:0009 */