Searched around for this, but the best result has only been to copy the string.
Given this simple snippet:
struct custom_string_traits: std::char_traits<char> {
static bool eq(char c, char d) { ... }
static bool lt(char c, char d) { ... }
...
};
typedef std::basic_string<char,custom_string_traits> my_string;
how might I perform operations such as
std::string foo = "baz";
my_string bar = "qux";
x::swap(foo, bar);
/* OR */
foo = std::move(bar);
I want to optimize away from my current procedure:
std::string foo = "baz";
my_string bar = "qux";
my_string next(foo.c_str(), foo.size());
foo.assign(bar.c_str(), bar.size());
Looked at C++ std::basic_string/char_traits specialization; not sure how to interpret it.