Funny quirk of the C++ standard library: std::set is defined like this according...

@jann@infosec.exchange

Funny quirk of the C++ standard library:
std::set is defined like this according to the standard (section associative.set.syn):

  template<class Key, class Compare = less<Key>, class Allocator = allocator<Key>>
class set;

So: Nice, you can supply a custom allocator and the set implementation will transparently use that instead of the standard allocator!

Except... it's an allocator whose template argument is the user-supplied key type? I was staring at documentation and thought it must be a typo, since you obviously also need space to store some kind of tree node in the allocated elements.

Turns out that this is not a typo, there is template magic going on (rebind_traits) to basically switch out the allocator's template type argument, so you might write std::map<A, std::less<A>, MyAllocator<A>> and think that that map will create a MyAllocator<A> but you'd (depending on implementation) actually get something like a MyAllocator<std::_Rb_tree_node<A>>.