mirror of
https://github.com/bolero-MURAKAMI/Sprout
synced 2025-08-03 12:49:50 +00:00
fix iota
This commit is contained in:
parent
51716cb4af
commit
2905965f24
4 changed files with 116 additions and 34 deletions
|
@ -11,22 +11,22 @@
|
|||
#include <algorithm>
|
||||
#include <iterator>
|
||||
#include <bitset>
|
||||
#include <utility>
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <sprout/container.hpp>
|
||||
#include <sprout/detail/io/ios_state.hpp>
|
||||
#include <testspr/typeinfo.hpp>
|
||||
|
||||
namespace testspr {
|
||||
//
|
||||
// print
|
||||
//
|
||||
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 << ' '; });
|
||||
std::cout << std::endl;
|
||||
}
|
||||
template<typename InputRange>
|
||||
void print(InputRange const& range) {
|
||||
testspr::print(sprout::begin(range), sprout::end(range));
|
||||
void print() {}
|
||||
template<typename Head, typename... Tail>
|
||||
void print(Head const& head, Tail const&... tail) {
|
||||
std::cout << head;
|
||||
testspr::print(tail...);
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -35,14 +35,53 @@ namespace testspr {
|
|||
void print_ln() {
|
||||
std::cout << std::endl;
|
||||
}
|
||||
template<typename T>
|
||||
void print_ln(T const& t) {
|
||||
std::cout << t << std::endl;
|
||||
template<typename... Args>
|
||||
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<typename Head, typename... Tail>
|
||||
void print_ln(Head const& head, Tail const&... tail) {
|
||||
std::cout << head;
|
||||
testspr::print_ln(tail...);
|
||||
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<typename Head, typename... Tail>
|
||||
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<typename InputIterator>
|
||||
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<typename InputRange>
|
||||
void print_range(InputRange const& range) {
|
||||
testspr::print_range(sprout::begin(range), sprout::end(range));
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -75,6 +114,54 @@ namespace testspr {
|
|||
void print_hl() {
|
||||
testspr::print_ln("--------------------------------------------------------------------------------");
|
||||
}
|
||||
|
||||
//
|
||||
// manip_holder
|
||||
//
|
||||
template<typename T>
|
||||
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<typename T, typename Elem, typename Traits>
|
||||
std::basic_ostream<Elem, Traits>& operator<<(std::basic_ostream<Elem, Traits>& lhs, testspr::manip_holder<T> const& rhs) {
|
||||
return lhs << rhs.get();
|
||||
}
|
||||
template<typename T, typename Elem, typename Traits>
|
||||
std::basic_istream<Elem, Traits>& operator>>(std::basic_istream<Elem, Traits>& lhs, testspr::manip_holder<T> const& rhs) {
|
||||
return lhs >> rhs.get();
|
||||
}
|
||||
//
|
||||
// manip
|
||||
//
|
||||
template<typename T>
|
||||
T&&
|
||||
manip(T&& t) {
|
||||
return std::forward<T>(t);
|
||||
}
|
||||
template<typename Elem, typename Traits>
|
||||
testspr::manip_holder<std::basic_ostream<Elem, Traits>& (*)(std::basic_ostream<Elem, Traits>&)>
|
||||
manip(std::basic_ostream<Elem, Traits>& (*pf)(std::basic_ostream<Elem, Traits>&)) {
|
||||
return pf;
|
||||
}
|
||||
template<typename Elem, typename Traits>
|
||||
testspr::manip_holder<std::basic_ios<Elem, Traits>& (*)(std::basic_ios<Elem, Traits>&)>
|
||||
manip(std::basic_ios<Elem, Traits>& (*pf)(std::basic_ios<Elem, Traits>&)) {
|
||||
return pf;
|
||||
}
|
||||
testspr::manip_holder<std::ios_base& (*)(std::ios_base&)>
|
||||
manip(std::ios_base& (*pf)(std::ios_base&)) {
|
||||
return pf;
|
||||
}
|
||||
} // namespace testspr
|
||||
|
||||
#endif // #ifndef TESTSPR_PRINT_HPP
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue