mercredi 22 mai 2019

Is it possible to use std::basic_string as a wrapper around char*?

I have third party library that returns char* (and wchar_t*) that are created in it by strdup (and wcsdup functions respectively).

I want to avoid calling free manually at the end of my code.

Is it possible to write an allocator for std::basic_string so that it would handle dealing with this c-strings returned by this library? Ideally I don't want to allocate any new memory at all and use memory blocks that were returned (strings are supposed to be constant).

Aucun commentaire:

Enregistrer un commentaire