std::string is a typedef of basic_string that already explicitly uses the default allocator. There is no way to use std::string another dispenser. Even if you created a new typedef from basic_string with the basic_string you need, it cannot be passed to the API waiting for std::string .
Unfortunately, I see no way to satisfy all the needs that you have indicated in any of the existing C ++ standards, if you cannot somehow remove one or more of your requirements.
One possible creative solution, if you are able to do this, would be to assign the "orignal" char* buffer as std::string using resize . Then you can swap enter this line in your new one so that it becomes the owner.
Mark b
source share