UPDATE
Per comments, answer, and additional research, I have come to the conclusion that there is typically no difference between a set
The problem is that you don't know the internal type which set
uses for nodes.
While I haven't figured out how to determine this at compile time, you can write a tracing allocator which prints out the sizeof
the node type when allocate
is called, as in:
template
struct SimpleAllocator : private std::allocator
{
using value_type = T;
using pointer = typename std::allocator::pointer;
using size_type = typename std::allocator::size_type;
pointer allocate(size_type n)
{
std::cout << "Allocator sizeof(T)==" << sizeof(T) << '\n';
return std::allocator::allocate(n);
}
void deallocate(pointer p, size_type n)
{ return std::allocator::deallocate(p, n); }
};
And a little test program (I'm testing with sets of ints):
std::set, SimpleAllocator> s;
s.insert(2);
On my system, I get output of:
Allocator sizeof(T)==32