[testspr] add print_ln variadic version

This commit is contained in:
bolero-MURAKAMI 2013-08-03 18:14:22 +09:00
parent 22be7201bb
commit d8cb7a7887
2 changed files with 11 additions and 2 deletions

View file

@ -2,6 +2,7 @@
#define SPROUT_STRING_TO_STRING_HPP #define SPROUT_STRING_TO_STRING_HPP
#include <sprout/config.hpp> #include <sprout/config.hpp>
#include <sprout/string/string.hpp>
#include <sprout/string/int_to_string.hpp> #include <sprout/string/int_to_string.hpp>
#include <sprout/string/float_to_string.hpp> #include <sprout/string/float_to_string.hpp>

View file

@ -25,16 +25,24 @@ namespace testspr {
// //
// print_ln // print_ln
// //
void print_ln() {
std::cout << std::endl;
}
template<typename T> template<typename T>
static void print_ln(T const& t) { void print_ln(T const& t) {
std::cout << t << std::endl; std::cout << t << std::endl;
} }
template<typename Head, typename... Tail>
void print_ln(Head const& head, Tail const&... tail) {
std::cout << head;
testspr::print_ln(tail...);
}
// //
// print_bits // print_bits
// //
template<typename T> template<typename T>
static void print_bits(T const& t) { void print_bits(T const& t) {
testspr::print_ln(std::bitset<sizeof(T) * 8>(t).template to_string<char>()); testspr::print_ln(std::bitset<sizeof(T) * 8>(t).template to_string<char>());
} }