use back_inserter within C++ transform algorithm

Viewed 1794
vector<string> v = {"AAAAidad", "bbbb", "ADWHIBQSDS", "Hi", "fes", "dafegrg", "QQEEQEQEQEQ
    E", "\"", "a"};
transform1(v.begin(), v.end(), back_inserter(v),
                     [] (string s) -> string{
                     for(char& c:s)
                     {
                          c = toupper(c);
                     }
                    return s;
                    });

with the code snippet above, I expect to insert capitalized string element at the end of v. Actually, however, I just get the following output

v = {"AAAAidad",    "bbbb", "ADWHIBQSDS",   "Hi",   "fes",  "dafegrg",  "QQEEQEQEQEQ",    "AAAAIDAD"}

Only the first string was capitalized and inserted. Where are the rest string element in the vector?

2 Answers
Related