Thursday, July 3, 2014

According to http://ift.tt/1j2JYSX, one class that can be used as an allocator type must meet many requirements. However, I cannot find the same requirements specified by the C++ standard. The standard only requires the allocator type must not be a non-class type. (see n3797 20.7.8.1)


If I have an empty class Alloc and a fully specialized std::allocator_traits<Alloc>, can I use Alloc as follows:



#include <vector>

struct Alloc {};

template<>
std::allocator_traits<Alloc>
{
// full definitions as per the requirements for std::allocator_traits<T>
};

int main()
{
std::vector<int, Alloc> coll;
coll.push_back(8);
}






http://ift.tt/1lYEhEJ