cplusplus.com is notoriously bad ... looking at the description of cppreference.com here
This function attempts to allocate a temporary buffer equal in size to the sequence to be sorted, usually by calling std :: get_temporary_buffer. If the distribution is not performed, a less efficient algorithm is selected.
get_temporary_buffer :
template< class T > std::pair< T*, std::ptrdiff_t > get_temporary_buffer( std::ptrdiff_t count )
So, although technically this should be an underestimated behavior in order to specialize it for your own class in the std , you apparently do not do this for production code, and in practice it works very reliably and will allow you to intercept the memory request and refusal of return.
namespace std { template <> std::pair<My_Class*, std::ptrdiff_t> get_temporary_buffer(std::ptrdiff_t) { return {0, 0}; } }
source share