list<string> lst;lst.push_back("первая");lst.push_back("вторая");lst.push_back("третья");
string str = "первая|вторая|третья";
list<string> lst;lst.push_back("первая");lst.push_back("вторая");lst.push_back("третья");ostringstream st;copy(lst.begin(), lst.end(), ostream_iterator<string>(st,"|"));string s = st.str();cout << s;
C++ (Qt)void convert(const list<string> &lst, string &str, const string & sep = "|") { list<string>::const_iterator it = lst.begin(); for (it != lst.end(); ++it) str += ((*it)+sep);}
list<int> lst;lst.push_back(1);lst.push_back(2);lst.push_back(3);ostringstream st;copy(lst.begin(), lst.end(), ostream_iterator<int>(st,"|"));string s = st.str();
list<int> lst;lst.push_back(1);lst.push_back(2);lst.push_back(3);ostringstream st;copy(lst.begin(), lst.end(), ostream_iterator<int>(st,"|"));string s = str_.str();
C++ (Qt)template <class InputIterator, class T>string convert(InputIterator first, InputIterator last, const string &sep = "|") { ostringstream st; copy(first, last, ostream_iterator<T>(st, sep)); return st.str();}template <class InputIterator>string convert<string>(InputIterator first, InputIterator last, const string &sep = "|") { string str; for (first != last; ++first) str += (*first)+sep; return str;}