/*============================================================================= Copyright (c) 2011-2014 Bolero MURAKAMI https://github.com/bolero-MURAKAMI/Sprout Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ #ifndef TESTSPR_PRINT_HPP #define TESTSPR_PRINT_HPP #include #include #include #include #include #include #include #include #include namespace testspr { // // print // void print() {} template void print(Head const& head, Tail const&... tail) { std::cout << head; testspr::print(tail...); } // // print_ln // void print_ln() { std::cout << std::endl; } template void print_ln(Args const&... args) { sprout::detail::io::ios_all_saver saver(std::cout); testspr::print(args...); std::cout << std::endl; } // // print_tokens // void print_tokens() { testspr::print_ln(); } template void print_tokens(Head const& head, Tail const&... tail) { sprout::detail::io::ios_all_saver saver(std::cout); testspr::print(head, ' '); testspr::print_tokens(tail...); } // // print_quotes // void print_quotes() { testspr::print_ln(); } template void print_quotes(Head const& head, Tail const&... tail) { sprout::detail::io::ios_all_saver saver(std::cout); testspr::print('\"', head, "\" "); testspr::print_quotes(tail...); } // // print_range // template void print_range(InputIterator first, InputIterator last) { sprout::detail::io::ios_all_saver saver(std::cout); for (; first != last; ++first) { std::cout << *first << ' '; } std::cout << std::endl; } template void print_range(InputRange const& range) { testspr::print_range(sprout::begin(range), sprout::end(range)); } // // print_bits // template void print_bits(T const& t) { testspr::print_ln(std::bitset(t).template to_string()); } // // print_typename // template void print_typename() { testspr::print_ln(testspr::typename_of()); } // // print_type // template void print_type() { testspr::print_typename >(); } // // print_hl // void print_hl() { testspr::print_ln("--------------------------------------------------------------------------------"); } // // manip_holder // template class manip_holder { public: typedef T value_type; private: value_type m_; public: manip_holder(value_type const& m) : m_(m) {} value_type const& get() const { return m_; } }; template std::basic_ostream& operator<<(std::basic_ostream& lhs, testspr::manip_holder const& rhs) { return lhs << rhs.get(); } template std::basic_istream& operator>>(std::basic_istream& lhs, testspr::manip_holder const& rhs) { return lhs >> rhs.get(); } // // manip // template T&& manip(T&& t) { return std::forward(t); } template testspr::manip_holder& (*)(std::basic_ostream&)> manip(std::basic_ostream& (*pf)(std::basic_ostream&)) { return pf; } template testspr::manip_holder& (*)(std::basic_ios&)> manip(std::basic_ios& (*pf)(std::basic_ios&)) { return pf; } testspr::manip_holder manip(std::ios_base& (*pf)(std::ios_base&)) { return pf; } } // namespace testspr #endif // #ifndef TESTSPR_PRINT_HPP