10 #include <boost/array.hpp> 16 template<
typename T>
struct short_print_proxy {
18 explicit short_print_proxy(T
const & v, std::size_t p): value(v), precision(p) {};
19 short_print_proxy(short_print_proxy<T>
const & rhs): value(rhs.value) {};
21 std::size_t precision;
24 template <
typename T> std::ostream & operator<<(std::ostream & os, short_print_proxy<T>
const & v) {
29 template<
typename T> detail::short_print_proxy<T const>
short_print(T
const & v, std::size_t p = 6) {
30 return detail::short_print_proxy<T const>(v, p);
34 std::ostream & operator<<(std::ostream & os, short_print_proxy<float>
const & v);
35 std::ostream & operator<<(std::ostream & os, short_print_proxy<double>
const & v);
36 std::ostream & operator<<(std::ostream & os, short_print_proxy<long double>
const & v);
39 std::ostream & print_for_sequence(std::ostream & os, T
const & value)
41 switch (value.size()) {\
45 return os <<
"[" <<
short_print(value.front()) <<
"]";\
54 std::ostream & operator<<(std::ostream & os, short_print_proxy<std::vector<T>
const>
const & v)
56 return print_for_sequence(os, v.value);
59 template <
typename T, std::
size_t N>
60 std::ostream & operator<<(std::ostream & os, short_print_proxy<boost::array<T, N>
const>
const & v)
62 return print_for_sequence(os, v.value);
detail::short_print_proxy< T const > short_print(T const &v, std::size_t p=6)