/** ** \file misc/separator.hh ** \brief Output containers with a separator between items. */ #pragma once #include #include namespace misc { template class separator { public: separator(const C& c, const S& s); std::ostream& operator()(std::ostream& o) const; private: const C& container_; const S& separator_; }; /// Shorthand to create separator(c, s). template separator separate(const C& c, const S& s); /// Shorthand to create separator(c, '\n'). template separator separate(const C& c); /// Output the separator object \a s on \a ostr. template inline std::ostream& operator<<(std::ostream& ostr, const separator& s); /// Output the pair \a p on \a ostr. /// Usefull if you want to to use a std::pair("something", misc::iendl) /// as your separator. template inline std::ostream& operator<<(std::ostream& ostr, const std::pair& p); } // namespace misc #include