Created
November 15, 2018 08:19
-
-
Save hutorny/aa44d108ca65fb3fc91c400ce2791ec5 to your computer and use it in GitHub Desktop.
A c++ template to print any iterable
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iterator> | |
#include <utility> | |
// see live example on http://coliru.stacked-crooked.com/a/591f4db5a008cb5a | |
template<class Stream, class Vector, class Begin = decltype(std::begin(std::declval<Vector>()))> | |
inline Stream& operator<<(Stream& stream, const Vector& vect) { | |
const char* dlm = ""; | |
for(const auto& i : vect) { stream << dlm << i; dlm = ", "; } | |
return stream; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment