/* */ #ifndef COMMON_HPP_INCLUDED #define COMMON_HPP_INCLUDED #include #include #include #include #include #define FMT(ss) (dynamic_cast< ::std::stringstream&>(::std::stringstream() << ss).str()) #include "include/debug.hpp" #include "include/rustic.hpp" // slice and option template struct LList { const LList* m_prev; T m_item; LList(const LList* prev, T item): m_prev(prev), m_item( ::std::move(item) ) { }; }; namespace std { template inline ::std::ostream& operator<<(::std::ostream& os, const ::std::vector& v) { if( v.size() > 0 ) { bool is_first = true; for( const auto& i : v ) { if(!is_first) os << ", "; is_first = false; os << *i; } } return os; } template inline ::std::ostream& operator<<(::std::ostream& os, const ::std::vector& v) { if( v.size() > 0 ) { bool is_first = true; for( const auto& i : v ) { if(!is_first) os << ", "; is_first = false; os << i; } } return os; } template inline ::std::ostream& operator<<(::std::ostream& os, const ::std::pair& v) { os << "(" << v.first << ", " << v.second << ")"; return os; } template inline ::std::ostream& operator<<(::std::ostream& os, const ::std::map& v) { if( v.size() > 0 ) { bool is_first = true; for( const auto& i : v ) { if(!is_first) os << ", "; is_first = false; os << i.first << ": " << i.second; } } return os; } template inline ::std::ostream& operator<<(::std::ostream& os, const ::std::multimap& v) { if( v.size() > 0 ) { bool is_first = true; for( const auto& i : v ) { if(!is_first) os << ", "; is_first = false; os << i.first << ": " << i.second; } } return os; } } #endif