>> try inheriting from std::string
As JaWiB mentioned, std::string and the other container classes are not meant to be inherited from. If anybody tries to use the class polymorphically, they could easily get undefined behavior. Even if they don't, a nonmember, nonfriend function is still preferred over creating an entirely new class to add functionality.