|
Boost Users : |
From: Daniel Krügler (dsp_at_[hidden])
Date: 2008-07-07 04:54:52
Sean Farrow wrote:
> Hi:
> What is the best way (in terms of efficiency) to convert an std::vector
> of wchar_t to std::wstring.
> I can think of a oupple of aproaches:
> 1. using std::copy.
> 2. using boost::lexical_cast.
> 3 using boost::foreach
> 4. Usin he boost::serialization library.
> The std::wstring doesn't ned to be output to a file.
> Any advice apreciated.
> Sean.
What about the sequence assignment capabilities of basic_string
itself, like this:
std::wstring from_vector(const std::vector<wchar_t>& src) {
return std::wstring(src.begin(), src.end());
}
?
For already existing std::wstring objects you could use
it's assign overload that accepts an input iterator pair.
HTH & greetings from Bremen,
Daniel Krügler
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net