When I do the following my compiler warns me of a possible loss of data (but the compilation is succesful):
std::vector<wchar_t> v1;
v1.push_back(L'a');
std::vector<char> v2(v1.begin(), v1.end());
When I do the following I get no such warning, and as far as I can tell I have not lost data when I've done it in the past:
std::wstring w1;
w1 = L"a";
std::string s1(w1.begin(), w1.end());
Is there in fact no possible loss of data in the second snippet? And if, not why not? Is there something in the basic_string constructor that handles the possibility of iterators of the other type of character? Or is it something special about the iterators themselves?