17 Library introduction [library]

17.6 Library-wide requirements [requirements]

17.6.4 Constraints on programs [constraints] Replacement functions [replacement.functions]

Clauses [language.support] through [thread] and Annex [depr] describe the behavior of numerous functions defined by the C++ standard library. Under some circumstances, however, certain of these function descriptions also apply to replacement functions defined in the program ([definitions]).

A C++ program may provide the definition for any of eight dynamic memory allocation function signatures declared in header <new> ([basic.stc.dynamic], [support.dynamic]):

  • operator new(std::size_t)

  • operator new(std::size_t, const std::nothrow_t&)

  • operator new[](std::size_t)

  • operator new[](std::size_t, const std::nothrow_t&)

  • operator delete(void*)

  • operator delete(void*, const std::nothrow_t&)

  • operator delete[](void*)

  • operator delete[](void*, const std::nothrow_t&)

The program's definitions are used instead of the default versions supplied by the implementation ([support.dynamic]). Such replacement occurs prior to program startup ([basic.def.odr], [basic.start]). The program's definitions shall not be specified as inline. No diagnostic is required.