// new standard header #ifndef _NEW_ #define _NEW_ #include _X_STD_BEGIN // CLASS bad_alloc class bad_alloc : public _XSTD exception { // base of all bad allocation exceptions public: #if __EDG__ || defined(__SUNPRO_CC) bad_alloc(const char *_Message = _MESG("bad allocation")) _THROW0() : exception(_Message) { // construct from message string } #else /* __EDG__ etc. */ bad_alloc() _THROW0() { // construct with no message string } virtual const char *what() const _THROW0() { // report a bad allocation return ("bad allocation"); } #endif /* __EDG__ etc. */ // virtual ~bad_alloc() _THROW0() // {} // destroy the object #if _HAS_EXCEPTIONS #else /* _HAS_EXCEPTIONS */ protected: virtual void _Doraise() const { // perform class-specific exception handling _RAISE(*this); } #endif /* _HAS_EXCEPTIONS */ }; _X_STD_END _STD_BEGIN // SUPPORT TYPES typedef void (*new_handler)(); // handler for operator new failures struct nothrow_t { // placement new tag type to suppress exceptions }; extern const nothrow_t nothrow; // constant for placement new tag // FUNCTION AND OBJECT DECLARATIONS new_handler set_new_handler(new_handler) _THROW0(); // establish alternate new handler extern new_handler _New_hand; // pointer to current new handler _STD_END // new AND delete DECLARATIONS (NB: NOT IN std) #if defined(__SUNPRO_CC) void operator delete(void *) throw(); // delete allocated storage void *operator new(_CSTD size_t) throw(std::bad_alloc); // allocate or throw exception #else /* defined(__SUNPRO_CC) */ void operator delete(void *) _THROW0(); // delete allocated storage void *operator new(_CSTD size_t) _THROW1(_XSTD bad_alloc); // allocate or throw exception #endif /* defined(__SUNPRO_CC) */ void *operator new(_CSTD size_t, const _STD nothrow_t&) _THROW0(); // allocate or return null pointer #if defined(__TI_COMPILER_VERSION__) void *operator new (std::size_t, void *ptr) _THROW0(); #else inline void *operator new(_CSTD size_t, void *_Where) _THROW0() { // construct with placement at _Where return (_Where); } #endif /* defined(__TI_COMPILER_VERSION__) */ #if defined(__SUNPRO_CC) void operator delete[](void *) throw(); // delete allocated array void *operator new[](_CSTD size_t) throw(std::bad_alloc); // allocate array or throw exception #else /* defined(__SUNPRO_CC) */ void operator delete[](void *) _THROW0(); // delete allocated array void *operator new[](_CSTD size_t) _THROW1(_XSTD bad_alloc); // allocate array or throw exception #endif /* defined(__SUNPRO_CC) */ void *operator new[](_CSTD size_t, const _STD nothrow_t&) _THROW0(); // allocate array or return null pointer #if defined(__TI_COMPILER_VERSION__) void *operator new[](std::size_t, void *ptr) _THROW0(); #else inline void *operator new[](_CSTD size_t, void *_Where) _THROW0() { // construct array with placement at _Where return (_Where); } #endif /* !defined(__TI_COMPILER_VERSION__) */ void operator delete(void *, const _STD nothrow_t&) _THROW0(); // delete if nothrow new fails -- REPLACEABLE void operator delete[](void *, const _STD nothrow_t&) _THROW0(); // delete if nothrow array new fails -- REPLACEABLE void operator delete(void *, void *) _THROW0(); // {} // delete if placement new fails void operator delete[](void *, void *) _THROW0(); // {} // delete if placement array new fails #endif /* _NEW_ */ /* * Copyright (c) 1992-2004 by P.J. Plauger. ALL RIGHTS RESERVED. * Consult your license regarding permissions and restrictions. V4.02:1476 */