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?
Prior to LWG2818, [contents]p3 read:
Whenever a name
xdefined in the standard library is mentioned, the namexis assumed to be fully qualified as::std::x, unless explicitly described otherwise. For example, if the Effects: element for library functionFis described as calling library functionG, the function::std::Gis meant.
So writing operator new in the specification would mean ::std::operator new, which wouldn't make sense. ::operator new correctly refers to operator new in the global namespace.
In an implementation of the standard library, there would be no difference between writing operator new and ::operator new since std::allocator<T> wouldn't define a member operator new and ADL has no effect since there is only one namespace a free operator new could be defined in.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With