The documentation for the std::allocator<T>::allocate
member function says in ([allocator.members]) that:
Remarks: The storage for the array is obtained by calling
::operator new
([new.delete]), but it is unspecified when or how often this function is called. This function starts the lifetime of the array object, but not that of any of the array elements.
I wonder why it says ::operator new
and not just operator new
? Does the double colon make any difference? Which other operator new
could be called here, if that double colon was omitted?
operator new
. But how is this related tostd::allocator
? – Elephantnew
is an operator, and as such is subject to the rules of ADL like other operators. By using::operator new
the ADL gets bypassed and only the global new defined by the compiler, or the global new you have replaced it with, will be used. – Sklaroperator new
could be selected by ADL here than that global one (compiler-defined or replaced)? – Elephantoperator new
. If they did so andallocate
just usednew T
then you would get that class overload of new instead of the global new.::operator new
stops that from happening even if the class overloadsnew
– Sklarstd::allocator<T>::allocate
usenew T
? It should just allocate and not initialize any objects of typeT
. Or am I wrong? – Elephantoperator new
, and now that I say that I get your confusion. They would have to useT::operator new
to get the class new. – Sklar