KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
What is the most elegant way, in your opinion, to print to std::cout using std::ostream_iterator in C++11 and avoid printing a trailing delimeter? The object I'm printing has bidirectional iterators, but not random access iterators. std::list<double> x{1,2,3,4,5,6}; std::copy(x.begin(), std::prev(x.end()), std::ostream_iterator<int>(std::cout, ",") ); if ( x.size() != 0 ) std::cout << *(--x.end()) << std::endl;
Tags (comma-separated)
Save Edits
Cancel