2

what :: does in line : return ::operator new(size, ::std::nothrow); and why the class is using template when there is no use for template type T

template<typename T>
class DefaultMemoryAllocator
{
public:
  static inline void *Allocate(size_t size)
  {
    return ::operator new(size, ::std::nothrow);
  }
  static inline void Deallocate(void *pointer, size_t size)
  {
    ::operator delete(pointer);
  }
};

1 Answers1

1

Using the scope resolution operator :: like this means that the global operator new and operator delete functions are called, as opposed to ones that might have been overridden for that class.

You'll probably find that this function is part of a memory policy class, and is called from the class' operator new and operator delete overridden functions.

Bathsheba
  • 231,907
  • 34
  • 361
  • 483