The problem is I don't understand why those should be separate. Why not use one class, like CharType, that would contain both the logic of char traits and char type. I mean replace that:
template <class _Elem, class _Traits = char_traits<_Elem>, class _Alloc = allocator<_Elem>>
class basic_string { /*...*/ };
with that:
template <class ExtendedTraits, class _Alloc = allocator<_Elem>>
class basic_string { /*...*/ };
where ExtendedTraits is the presaid combination of _Elem and _Traits, that might look like that:
template<_CharType> //all the necessary template parameters
class extended_traits
{
public:
using value_type = _CharType;
private:
_CharType _elem;
public:
//... all methods, that used to be in char_traits but now non-static and accepting one parameter
};
I tried to implement both approaches, both of them do work, but there may be some problems I still do not notice.