Created
December 23, 2011 11:00
-
-
Save piti118/1513875 to your computer and use it in GitHub Desktop.
Vector Inserter
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 <vector> | |
//vector_inserter(idea taken from boost for those who don't wanna install boost) | |
//try vector<int> v; v+=1,2,3,4,5,6; | |
template <class T> class vector_inserter{ | |
public: | |
std::vector<T>& v; | |
vector_inserter(std::vector<T>& v):v(v){} | |
vector_inserter& operator,(const T& val){v.push_back(val);return *this;} | |
}; | |
template <class T> vector_inserter<T>& operator+=(std::vector<T>& v,const T& x){ | |
return vector_inserter<T>(v),x; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment