Is it possible to overload the operator new to be constexpr function? Something like:
constexpr void * operator new( std::size_t count );
The reason why would be to execute constexpr function within the overloaded operator body where count argument value would be an input data... As the operator is invoked by:
SomeClass * foo = new SomeClass();
The size of the data type is know at compile time, isn’t it? (count== sizeof(SomeClass)
) So the count can be considered as compile time constant?
constexpr void * operator new( std::size_t count )
{
if constexpr ( count >= 10 ) { /* do some compile-time business */ }
}
Many thanks in advance to anyone willing to help!