Created
May 25, 2011 19:37
-
-
Save shnya/991726 to your computer and use it in GitHub Desktop.
debug
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
struct DDMY{ ostringstream o; template<class T>DDMY& operator,(const T &t){o<<t<<",";return *this;} string operator*(){ return o.str().substr(0,o.str().size()-1); } }; | |
#define debug(args...) cout<<"("#args")=("<< *(DDMY(),args)<<") (L"<<__LINE__<<")"<<endl | |
template<class T> std::ostream &operator<<(std::ostream &o,const std::vector<T> &v) | |
{ o << "["; for(std::size_t i=0;i<v.size();i++) o << v[i] << (i < v.size()-1 ? ",":""); return o << "]"; } | |
template<class T,class U> std::ostream &operator<<(std::ostream &o,const std::pair<T,U> &v) | |
{ return o << v.first << ":" << v.second; } | |
template<class T,class U> std::ostream &operator<<(std::ostream &o,const std::map<T,U> &v) | |
{ o << "{"; typename std::map<T,U>::const_iterator i=v.begin(),j=i;++j;for(;i!=v.end();++i,++j) o << *i << (j!=v.end()? ",":""); return o << "}"; } | |
template<class T> std::ostream &operator<<(std::ostream &o,const std::set<T> &v) | |
{ o << "{"; typename std::set<T>::const_iterator i=v.begin(),j=i;++j;for(;i!=v.end();++i,++j) o << *i << (j!=v.end()? ",":""); return o << "}"; } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment