string - What is the recommended way to flatten a std::vector<CString> to a multi_sz using C++ / STL -


i want write list of strings (atl::cstring) stored in std::vector reg_multi_sz value in windows registry. know how in plain c (iterate once total length, allocate buffer, copy strings buffer separated "\0").

know tried following using stl (sorry have use vs2010 "for each"):

std::vector<tchar> multiline_sz; each ( cstring entry in mystringlist ) {    tchar* buf = entry.getbuffer();    multiline_sz.insert(multiline_sz.end(), &buf[0], &buf[entry.getlength()]);    multiline_sz.push_back(l'\0'); } multiline_sz.push_back(l'\0'); 

this works, wonder if there more elegant or faster way using stl.

cstring::getbuffer() zero-terminated, it's valid do

for each ( cstring entry in mystringlist ) {    tchar const* buf = entry.getbuffer();    multiline_sz.insert(multiline_sz.end(), &buf[0], &buf[entry.getlength()+1]); } 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -