#ifndef LIMONP_STD_EXTEMSION_HPP #define LIMONP_STD_EXTEMSION_HPP #include #ifdef __APPLE__ #include #include #elif(__cplusplus >= 201103L) #include #include #elif defined _MSC_VER #include #include #else #include #include namespace std { using std::tr1::unordered_map; using std::tr1::unordered_set; } #endif #include #include #include #include #include #include namespace std { template ostream& operator << (ostream& os, const vector& v) { if(v.empty()) { return os << "[]"; } os<<"["< inline ostream& operator << (ostream& os, const vector& v) { if(v.empty()) { return os << "[]"; } os<<"[\""< ostream& operator << (ostream& os, const deque& dq) { if(dq.empty()) { return os << "[]"; } os<<"[\""< ostream& operator << (ostream& os, const pair& pr) { os << pr.first << ":" << pr.second ; return os; } template string& operator << (string& str, const T& obj) { stringstream ss; ss << obj; // call ostream& operator << (ostream& os, return str = ss.str(); } template ostream& operator << (ostream& os, const map& mp) { if(mp.empty()) { os<<"{}"; return os; } os<<'{'; typename map::const_iterator it = mp.begin(); os<<*it; it++; while(it != mp.end()) { os<<", "<<*it; it++; } os<<'}'; return os; } template ostream& operator << (ostream& os, const std::unordered_map& mp) { if(mp.empty()) { return os << "{}"; } os<<'{'; typename std::unordered_map::const_iterator it = mp.begin(); os<<*it; it++; while(it != mp.end()) { os<<", "<<*it++; } return os<<'}'; } template ostream& operator << (ostream& os, const set& st) { if(st.empty()) { os << "{}"; return os; } os<<'{'; typename set::const_iterator it = st.begin(); os<<*it; it++; while(it != st.end()) { os<<", "<<*it; it++; } os<<'}'; return os; } template bool IsIn(const ContainType& contain, const KeyType& key) { return contain.end() != contain.find(key); } template basic_string & operator << (basic_string & s, ifstream & ifs) { return s.assign((istreambuf_iterator(ifs)), istreambuf_iterator()); } template ofstream & operator << (ofstream & ofs, const basic_string& s) { ostreambuf_iterator itr (ofs); copy(s.begin(), s.end(), itr); return ofs; } } // namespace std #endif