5 #ifndef DISPLACE_PRETTYPRINT_H 6 #define DISPLACE_PRETTYPRINT_H 14 #include <type_traits> 15 #include <unordered_set> 35 template <
typename C>
static yes & test(
typename C::const_iterator*);
36 template <
typename C>
static no & test(...);
38 static const bool value =
sizeof(test<T>(
nullptr)) ==
sizeof(
yes);
47 static yes & f(
typename std::enable_if<
48 std::is_same<decltype(
static_cast<typename C::const_iterator(C::*)() const
>(&C::begin)),
49 typename C::const_iterator(C::*)()
const>::
value>::type *);
51 template <
typename C>
static no & f(...);
54 static yes & g(
typename std::enable_if<
55 std::is_same<decltype(
static_cast<typename C::const_iterator(C::*)() const
>(&
C::end)),
56 typename C::const_iterator(C::*)()
const>::
value,
void>::type*);
58 template <
typename C>
static no &
g(...);
61 static bool const beg_value =
sizeof(f<T>(
nullptr)) ==
sizeof(
yes);
62 static bool const end_value =
sizeof(g<T>(
nullptr)) ==
sizeof(
yes);
70 template <
typename TChar>
82 template <
typename T,
typename TChar>
95 typename TChar = char,
96 typename TCharTraits = ::std::char_traits<TChar>,
103 template <
typename U>
112 const auto the_end =
end(c);
120 if (++it == the_end)
break;
122 if (delimiters_type::values.delimiter != NULL)
123 stream << delimiters_type::values.delimiter;
130 : container_(container)
135 if (delimiters_type::values.prefix != NULL)
136 stream << delimiters_type::values.prefix;
140 if (delimiters_type::values.postfix != NULL)
141 stream << delimiters_type::values.postfix;
145 const T & container_;
150 template <
typename T,
typename TChar,
typename TCharTraits,
typename TDelimiters>
151 template <
typename T1,
typename T2>
160 stream << print_container_helper<T, TChar, TCharTraits, TDelimiters>::delimiters_type::values.delimiter;
167 template <
typename T,
typename TChar,
typename TCharTraits,
typename TDelimiters>
168 template <
typename ...Args>
174 template <std::
size_t I>
struct Int { };
178 tuple_print(c, stream, Int<0>());
186 typename std::conditional<
sizeof...(Args) != 0, Int<0>, std::nullptr_t>::type)
188 stream << std::get<0>(c);
189 tuple_print(c, stream, Int<1>());
192 template <std::
size_t N>
196 stream << print_container_helper<T, TChar, TCharTraits, TDelimiters>::delimiters_type::values.delimiter;
198 stream << std::get<N>(c);
200 tuple_print(c, stream, Int<N + 1>());
206 template<
typename T,
typename TChar,
typename TCharTraits,
typename TDelimiters>
208 std::basic_ostream<TChar, TCharTraits> & stream,
218 template <
typename T>
220 detail::has_const_iterator<T>::value &&
221 detail::has_begin_end<T>::beg_value &&
222 detail::has_begin_end<T>::end_value> { };
224 template <
typename T, std::
size_t N>
227 template <std::
size_t N>
230 template <
typename T>
233 template <
typename T1,
typename T2>
236 template <
typename ...Args>
250 template <
typename T,
typename TComp,
typename TAllocator>
253 template <
typename T,
typename TComp,
typename TAllocator>
256 template <
typename T,
typename TComp,
typename TAllocator>
259 template <
typename T,
typename TComp,
typename TAllocator>
262 template <
typename T,
typename TComp,
typename TAllocator>
265 template <
typename T,
typename TComp,
typename TAllocator>
268 template <
typename T,
typename TComp,
typename TAllocator>
271 template <
typename T,
typename TComp,
typename TAllocator>
274 template <
typename T,
typename THash,
typename TEqual,
typename TAllocator>
277 template <
typename T,
typename THash,
typename TEqual,
typename TAllocator>
280 template <
typename T,
typename THash,
typename TEqual,
typename TAllocator>
283 template <
typename T,
typename THash,
typename TEqual,
typename TAllocator>
286 template <
typename T,
typename THash,
typename TEqual,
typename TAllocator>
289 template <
typename T,
typename THash,
typename TEqual,
typename TAllocator>
292 template <
typename T,
typename THash,
typename TEqual,
typename TAllocator>
295 template <
typename T,
typename THash,
typename TEqual,
typename TAllocator>
319 virtual std::ostream &
stream(::std::ostream &) = 0;
320 virtual std::wostream &
stream(::std::wostream &) = 0;
323 template <
typename T,
typename Delims>
330 return s << print_container_helper<T, char, std::char_traits<char>, Delims>(t);
333 std::wostream &
stream(std::wostream & s)
335 return s << print_container_helper<T, wchar_t, std::char_traits<wchar_t>, Delims>(t);
342 template <
typename Delims>
345 template <
typename Container>
348 std::unique_ptr<custom_delims_base>
base;
351 template <
typename TChar,
typename TCharTraits,
typename Delims>
354 return p.
base->stream(s);
372 const T *
const _array;
380 template <
typename T>
388 return m_map.cbegin(n);
393 return m_map.cend(n);
428 template<
typename T,
typename TChar,
typename TCharTraits>
430 std::basic_ostream<TChar, TCharTraits> &>::type
431 operator<<(std::basic_ostream<TChar, TCharTraits> & stream,
const T & container)
433 return stream << ::utils::print_container_helper<T, TChar, TCharTraits>(container);
437 #endif //DISPLACE_PRETTYPRINT_H const_iterator end() const
Definition: prettyprint.h:391
Definition: prettyprint.h:104
const_iterator begin() const
Definition: prettyprint.h:368
Definition: prettyprint.h:71
Definition: prettyprint.h:316
print_container_helper(const T &container)
Definition: prettyprint.h:129
Definition: prettyprint.h:362
static const delimiters_values< char > values
Definition: prettyprint.h:263
static const delimiters_values< wchar_t > values
Definition: prettyprint.h:303
static const delimiters_values< wchar_t > values
Definition: prettyprint.h:293
static void print_body(const U &c, ostream_type &stream)
Definition: prettyprint.h:106
char yes
Definition: prettyprint.h:27
static const delimiters_values< wchar_t > values
Definition: prettyprint.h:308
std::wostream & stream(std::wostream &s)
Definition: prettyprint.h:333
bucket_print_wrapper(const T &m, size_type bucket)
Definition: prettyprint.h:396
static const delimiters_values< char > values
Definition: prettyprint.h:306
Definition: pathshop.cpp:8
static const delimiters_values< char > values
Definition: prettyprint.h:251
Definition: prettyprint.h:25
static const delimiters_values< char > values
Definition: prettyprint.h:242
T::size_type size_type
Definition: prettyprint.h:384
std::basic_ostream< TChar, TCharTraits > ostream_type
Definition: prettyprint.h:101
utils::bucket_print_wrapper< T > bucket_print(const T &m, typename T::size_type n)
Definition: prettyprint.h:415
utils::array_wrapper_n< T > pretty_print_array(const T *const a, size_t n)
Definition: prettyprint.h:409
void operator()(ostream_type &stream) const
Definition: prettyprint.h:133
Definition: prettyprint.h:343
Definition: prettyprint.h:324
const_iterator begin() const
Definition: prettyprint.h:386
static void print_body(const std::pair< T1, T2 > &c, ostream_type &stream)
Definition: prettyprint.h:156
T::const_local_iterator const_iterator
Definition: prettyprint.h:383
Definition: prettyprint.h:83
static const delimiters_values< wchar_t > values
Definition: prettyprint.h:281
static const delimiters_values< char > values
Definition: prettyprint.h:301
const char_type * prefix
Definition: prettyprint.h:74
TChar char_type
Definition: prettyprint.h:73
virtual std::ostream & stream(::std::ostream &)=0
const_iterator end() const
Definition: prettyprint.h:369
std::pair< box, unsigned > value
Definition: diffusion.cpp:30
const T * const_iterator
Definition: prettyprint.h:364
typename print_container_helper< T, TChar, TCharTraits, TDelimiters >::ostream_type ostream_type
Definition: prettyprint.h:171
static const delimiters_values< wchar_t > values
Definition: prettyprint.h:244
static bool const beg_value
Definition: prettyprint.h:61
Definition: prettyprint.h:219
Definition: prettyprint.h:98
std::enable_if< ::utils::is_container< T >::value, std::basic_ostream< TChar, TCharTraits > & >::type operator<<(std::basic_ostream< TChar, TCharTraits > &stream, const T &container)
Definition: prettyprint.h:431
std::tuple< Args... > element_type
Definition: prettyprint.h:172
static bool const end_value
Definition: prettyprint.h:62
Definition: prettyprint.h:32
static const type values
Definition: prettyprint.h:86
std::ostream & stream(std::ostream &s)
Definition: prettyprint.h:328
custom_delims(const Container &c)
Definition: prettyprint.h:346
typename print_container_helper< T, TChar, TCharTraits, TDelimiters >::ostream_type ostream_type
Definition: prettyprint.h:154
static void print_body(const element_type &c, ostream_type &stream)
Definition: prettyprint.h:176
array_wrapper_n(const T *const a, size_t n)
Definition: prettyprint.h:367
Definition: prettyprint.h:19
static const delimiters_values< char > values
Definition: prettyprint.h:287
std::unique_ptr< custom_delims_base > base
Definition: prettyprint.h:348
const char_type * delimiter
Definition: prettyprint.h:75
yes[2] no
Definition: prettyprint.h:28
static void tuple_print(const element_type &c, ostream_type &stream, Int< N >)
Definition: prettyprint.h:193
Definition: prettyprint.h:381
static const delimiters_values< wchar_t > values
Definition: prettyprint.h:269
virtual ~custom_delims_base()
Definition: prettyprint.h:318
std::basic_ostream< TChar, TCharTraits > & operator<<(std::basic_ostream< TChar, TCharTraits > &stream, const print_container_helper< T, TChar, TCharTraits, TDelimiters > &helper)
Definition: prettyprint.h:207
T value_type
Definition: prettyprint.h:365
TDelimiters delimiters_type
Definition: prettyprint.h:100
Definition: prettyprint.h:43
T type
Definition: prettyprint.h:39
static const delimiters_values< wchar_t > values
Definition: prettyprint.h:257
static const delimiters_values< char > values
Definition: prettyprint.h:275
const char_type * postfix
Definition: prettyprint.h:76
custom_delims_wrapper(const T &t_)
Definition: prettyprint.h:326
static void tuple_print(const element_type &, ostream_type &, Int< sizeof...(Args)>)
Definition: prettyprint.h:181
static void tuple_print(const element_type &c, ostream_type &stream, typename std::conditional< sizeof...(Args) !=0, Int< 0 >, std::nullptr_t >::type)
Definition: prettyprint.h:185
T * end(T(&pArray)[N])
Definition: myutils.cpp:49