Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

104 lines
2.8 KiB

  1. // new standard header for Microsoft
  2. #pragma once
  3. #ifndef _NEW_
  4. #define _NEW_
  5. #include <exception>
  6. #pragma pack(push,8)
  7. #pragma warning(push,3)
  8. _STD_BEGIN
  9. // CLASS bad_alloc
  10. class bad_alloc
  11. : public exception
  12. { // base of all bad allocation exceptions
  13. public:
  14. bad_alloc(const char *_Message = _MESG("bad allocation")) _THROW0()
  15. : exception(_Message)
  16. { // construct from message string
  17. }
  18. virtual ~bad_alloc() _THROW0()
  19. { // destroy the object
  20. }
  21. #if !_HAS_EXCEPTIONS
  22. protected:
  23. virtual void _Doraise() const
  24. { // perform class-specific exception handling
  25. _RAISE(*this);
  26. }
  27. #endif /* _HAS_EXCEPTIONS */
  28. };
  29. // SUPPORT TYPES
  30. #if !defined(_INC_NEW) || !defined(_MSC_EXTENSIONS)
  31. typedef void (__cdecl *new_handler)(); // handler for operator new failures
  32. #endif
  33. struct nothrow_t
  34. { // placement new tag type to suppress exceptions
  35. };
  36. extern _CRTIMP2 const nothrow_t nothrow; // constant for placement new tag
  37. // FUNCTION AND OBJECT DECLARATIONS
  38. _CRTIMP2 new_handler __cdecl set_new_handler(new_handler)
  39. _THROW0(); // establish alternate new handler
  40. _STD_END
  41. // new AND delete DECLARATIONS (NB: NOT IN std)
  42. void __cdecl operator delete(void *) _THROW0();
  43. void *__cdecl operator new(size_t) _THROW1(std::bad_alloc);
  44. void *__cdecl operator new(size_t, const std::nothrow_t&)
  45. _THROW0();
  46. #ifndef __PLACEMENT_NEW_INLINE
  47. #define __PLACEMENT_NEW_INLINE
  48. inline void *__cdecl operator new(size_t, void *_Where) _THROW0()
  49. { // construct array with placement at _Where
  50. return (_Where);
  51. }
  52. inline void __cdecl operator delete(void *, void *) _THROW0()
  53. { // delete if placement new fails
  54. }
  55. #endif /* __PLACEMENT_NEW_INLINE */
  56. #ifndef __PLACEMENT_VEC_NEW_INLINE
  57. #define __PLACEMENT_VEC_NEW_INLINE
  58. inline void *__cdecl operator new[](size_t, void *_Where) _THROW0()
  59. { // construct array with placement at _Where
  60. return (_Where);
  61. }
  62. inline void __cdecl operator delete[](void *, void *) _THROW0()
  63. { // delete if placement array new fails
  64. }
  65. #endif /* __PLACEMENT_VEC_NEW_INLINE */
  66. void __cdecl operator delete[](void *) _THROW0(); // delete allocated array
  67. void *__cdecl operator new[](size_t)
  68. _THROW1(std::bad_alloc); // allocate array or throw exception
  69. void *__cdecl operator new[](size_t, const std::nothrow_t&)
  70. _THROW0(); // allocate array or return null pointer
  71. void __cdecl operator delete(void *, const std::nothrow_t&)
  72. _THROW0(); // delete if nothrow new fails -- REPLACEABLE
  73. void __cdecl operator delete[](void *, const std::nothrow_t&)
  74. _THROW0(); // delete if nothrow array new fails -- REPLACEABLE
  75. #if !defined(_INC_NEW) || !defined(_MSC_EXTENSIONS)
  76. using std::new_handler;
  77. #endif
  78. #pragma warning(pop)
  79. #pragma pack(pop)
  80. #endif /* _NEW_ */
  81. /*
  82. * Copyright (c) 1992-2001 by P.J. Plauger. ALL RIGHTS RESERVED.
  83. * Consult your license regarding permissions and restrictions.
  84. V3.10:0009 */