Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- BEFORE
- ==================================
- template <typename T>
- std::string join(T const &v, const std::string& s = ",")
- {
- std::stringstream str;
- for(typename T::const_iterator i = v.begin(); i != v.end(); ++i) {
- str << *i;
- if (std::next(i) != v.end())
- str << s;
- }
- return str.str();
- }
- AFTER
- ==================================
- template <typename T>
- std::string join(T const &v, const std::string& s = ",")
- {
- using move_iter = std::move_iterator<typename T::const_iterator>;
- return std::accumulate(move_iter(v.begin()), move_iter(v.end()), s);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement