I need to override only length function from std::basic_string because it's not correct for a custom char type on a specific platform. This is current declaration for, let's say, CustomString
typedef STL::basic_string<CustomChar, STL::char_traits<CustomChar>, STL::allocator<CustomChar> > CustomString;
I need to have a class that behaves as CustomString, but with the length function changed.
You need to specialise the
std::char_traits structure and override its
static size_t length(const char_type* s); function to do that.
Then you don’t even need to specify all the template parameters when instantiating a
basic_string. The following definition should be enough:
typedef std::basic_string<CustomChar> CustomString;