You can't write it like that:
template <class Data, class Allocator>
class Node;
template <class Data, class Allocator =
std::allocator<Node<Data, std::allocator<Node<...> >
class Node : public Data {
// ...
};
Because the default argument will have to repeat itself. You can use a tag-type, though
struct DefaultAllocatorTag { };
template<typename Alloc, typename Node>
struct SelectAllocator {
typedef Alloc type;
};
template<typename Node>
struct SelectAllocator<DefaultAllocatorTag, Node> {
typedef std::allocator<Node> type;
};
template <class Data, class Allocator = DefaultAllocatorTag >
class Node : public Data {
typedef typename SelectAllocator<Allocator, Node>::type
NodeAllocator;
};
If it is applicable, i would determine the allocator in the container, though. Like this:
template<typename Data, typename Allocator = std::allocator<Data> >
struct Container {
struct Node : Data {
typedef typename Allocator::template rebind<Node>::other NodeAllocator;
...
};
...
};