Let's say I have a
string s;
and I know exactly what allocator string s is using.
Then I have separately allocated buffer
char *buf = allocator<char> ::allocate(bufl en);
which is initialized with same allocator as compatible with string s.
1) How can I make 's' point to 'buf' (to 'attach') ?
(to avoid copying that "string s(buf, len)" would do ?)
2) How do I 'detach' buffer pointer from the string, that
is obtain s.data() + simultaneously reset
internal data ptr of s to NULL (and its length, too) ?
Weird tricks (that work) are welcome ...
Alex Perlov
--
Spellchecker: Misspelled word: "allocator"
Spellchecker: Replace with: alligator
string s;
and I know exactly what allocator string s is using.
Then I have separately allocated buffer
char *buf = allocator<char> ::allocate(bufl en);
which is initialized with same allocator as compatible with string s.
1) How can I make 's' point to 'buf' (to 'attach') ?
(to avoid copying that "string s(buf, len)" would do ?)
2) How do I 'detach' buffer pointer from the string, that
is obtain s.data() + simultaneously reset
internal data ptr of s to NULL (and its length, too) ?
Weird tricks (that work) are welcome ...
Alex Perlov
--
Spellchecker: Misspelled word: "allocator"
Spellchecker: Replace with: alligator
Comment