What I do not understand in the Alexandrescu policy based design is the creation of new types without anything in common where, in my opinion, there is still a lot in common that should be represented somehow.
For example, std::string
and std::basic_string<>
: allocator are something very internal and, in my opinion, the code using that class shall not be aware of which allocator that class is using.
BUT since a new type has been created, let's say std::basic_string_1
, all those methods which are passing around an std::string&
are basically broken, and I can't see a valid reason why an std::basic_string<>
with a different allocator shall be considered totally different from an std::basic_string<>
with another allocator.
My question is: why there is not common parent for every std::basic_string<>
, so that this problem could be avoided? Generally in my code when I have a Whatever<T>
, I make it inherits from a WhateverBase
of some sort, and when T
is not shown on the public interface of that class, it works greatfully...