2011-12-23 11:59:33 +00:00
|
|
|
#ifndef TESTSPR_PRINT_HPP
|
|
|
|
#define TESTSPR_PRINT_HPP
|
|
|
|
|
|
|
|
#include <algorithm>
|
|
|
|
#include <iterator>
|
2012-02-25 02:51:23 +00:00
|
|
|
#include <bitset>
|
2011-12-23 11:59:33 +00:00
|
|
|
#include <iostream>
|
2012-03-31 07:24:13 +00:00
|
|
|
#include <sprout/container.hpp>
|
2012-06-16 06:35:10 +00:00
|
|
|
#include <testspr/typeinfo.hpp>
|
2011-12-23 11:59:33 +00:00
|
|
|
|
|
|
|
namespace testspr {
|
|
|
|
//
|
|
|
|
// print
|
|
|
|
//
|
2013-08-07 13:13:03 +00:00
|
|
|
template<typename InputIterator>
|
|
|
|
void print(InputIterator first, InputIterator last) {
|
|
|
|
std::for_each(first, last, [](typename std::iterator_traits<InputIterator>::value_type const& e){ std::cout << e << ' '; });
|
2011-12-23 11:59:33 +00:00
|
|
|
std::cout << std::endl;
|
|
|
|
}
|
2013-08-07 13:13:03 +00:00
|
|
|
template<typename InputRange>
|
|
|
|
void print(InputRange const& range) {
|
2012-02-25 02:51:23 +00:00
|
|
|
testspr::print(sprout::begin(range), sprout::end(range));
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// print_ln
|
|
|
|
//
|
2013-08-03 09:14:22 +00:00
|
|
|
void print_ln() {
|
|
|
|
std::cout << std::endl;
|
|
|
|
}
|
2012-02-25 02:51:23 +00:00
|
|
|
template<typename T>
|
2013-08-03 09:14:22 +00:00
|
|
|
void print_ln(T const& t) {
|
2012-02-25 02:51:23 +00:00
|
|
|
std::cout << t << std::endl;
|
|
|
|
}
|
2013-08-03 09:14:22 +00:00
|
|
|
template<typename Head, typename... Tail>
|
|
|
|
void print_ln(Head const& head, Tail const&... tail) {
|
|
|
|
std::cout << head;
|
|
|
|
testspr::print_ln(tail...);
|
|
|
|
}
|
2012-02-25 02:51:23 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// print_bits
|
|
|
|
//
|
|
|
|
template<typename T>
|
2013-08-03 09:14:22 +00:00
|
|
|
void print_bits(T const& t) {
|
2012-02-25 02:51:23 +00:00
|
|
|
testspr::print_ln(std::bitset<sizeof(T) * 8>(t).template to_string<char>());
|
2011-12-23 11:59:33 +00:00
|
|
|
}
|
|
|
|
|
2012-06-16 06:35:10 +00:00
|
|
|
//
|
|
|
|
// print_typename
|
|
|
|
//
|
|
|
|
template<typename T>
|
|
|
|
void print_typename() {
|
|
|
|
testspr::print_ln(testspr::typename_of<T>());
|
|
|
|
}
|
|
|
|
|
2012-10-27 16:04:13 +00:00
|
|
|
//
|
|
|
|
// print_type
|
|
|
|
//
|
|
|
|
template<typename T>
|
|
|
|
void print_type() {
|
|
|
|
testspr::print_typename<testspr::id<T> >();
|
|
|
|
}
|
|
|
|
|
2011-12-23 11:59:33 +00:00
|
|
|
//
|
|
|
|
// print_hl
|
|
|
|
//
|
|
|
|
void print_hl() {
|
2012-02-25 02:51:23 +00:00
|
|
|
testspr::print_ln("--------------------------------------------------------------------------------");
|
2011-12-23 11:59:33 +00:00
|
|
|
}
|
|
|
|
} // namespace testspr
|
|
|
|
|
|
|
|
#endif // #ifndef TESTSPR_PRINT_HPP
|