18# include <tr1/unordered_set>
24 template <
bool,
typename S,
typename T>
struct conditional { };
25 template <
typename S,
typename T>
struct conditional<true, S, T> {
typedef S
type; };
26 template <
typename S,
typename T>
struct conditional<false, S, T> {
typedef T
type; };
38 typedef struct {
char array[2]; } no;
40 template<
typename C>
static yes test(
typename C::const_iterator*);
41 template<
typename C>
static no test(...);
43 static const bool value =
sizeof(test<T>(0)) ==
sizeof(yes);
54 typedef typename TType::const_iterator
iter;
59 template<
typename C, C>
struct ChT;
62 template<
typename C>
static char (&
f(...))[2];
64 template<
typename C>
static char (&
g(...))[2];
66 static bool const beg_value =
sizeof(f<Derived>(0)) == 2;
67 static bool const end_value =
sizeof(g<Derived>(0)) == 2;
74 template<
typename T, std::
size_t N>
struct is_container<T[N]> {
static const bool value =
true; };
81 template<
typename TChar>
93 template<
typename T,
typename TChar>
111 template<
typename T,
typename TComp,
typename TAllocator>
114 template<
typename T,
typename TComp,
typename TAllocator>
117 template<
typename T,
typename TComp,
typename TAllocator>
120 template<
typename T,
typename TComp,
typename TAllocator>
123 template<
typename T,
typename TComp,
typename TAllocator>
126 template<
typename T,
typename TComp,
typename TAllocator>
129 template<
typename T,
typename TComp,
typename TAllocator>
132 template<
typename T,
typename TComp,
typename TAllocator>
136 template<
typename T,
typename THash,
typename TEqual,
typename TAllocator>
139 template<
typename T,
typename THash,
typename TEqual,
typename TAllocator>
142 template<
typename T,
typename THash,
typename TEqual,
typename TAllocator>
145 template<
typename T,
typename THash,
typename TEqual,
typename TAllocator>
148 template<
typename T,
typename THash,
typename TEqual,
typename TAllocator>
151 template<
typename T,
typename THash,
typename TEqual,
typename TAllocator>
154 template<
typename T,
typename THash,
typename TEqual,
typename TAllocator>
157 template<
typename T,
typename THash,
typename TEqual,
typename TAllocator>
173 template <
typename T, std::
size_t N>
struct get_iterator<T[N]> {
typedef const T *
iter; };
177 template <
typename T,
size_t N>
const T *
begin(
const T(&x)[N]) {
return &x[0]; }
178 template <
typename T,
size_t N>
const T *
end (
const T(&x)[N]) {
return &x[0] + N; }
182 template<
typename T,
typename TChar =
char,
typename TCharTraits = ::std::
char_traits<TChar>,
typename TDelimiters = delimiters<T, TChar> >
191 : _container(container)
197 if (delimiters_type::values.prefix != NULL)
198 stream << delimiters_type::values.prefix;
200 if (
begin(_container) !=
end(_container))
201 for (
TIter it =
begin(_container), it_end =
end(_container); ; )
205 if (++it == it_end)
break;
207 if (delimiters_type::values.delimiter != NULL)
208 stream << delimiters_type::values.delimiter;
211 if (delimiters_type::values.postfix != NULL)
212 stream << delimiters_type::values.postfix;
216 const T & _container;
227 virtual ::std::ostream &
stream(::std::ostream &) = 0;
228 virtual ::std::wostream &
stream(::std::wostream &) = 0;
231 template<
typename T,
typename Delims>
236 ::std::ostream &
stream(::std::ostream & s)
238 return s << ::pretty_print::print_container_helper<T, char, ::std::char_traits<char>, Delims>(t);
240 ::std::wostream &
stream(::std::wostream & s)
242 return s << ::pretty_print::print_container_helper<T, wchar_t, ::std::char_traits<wchar_t>, Delims>(t);
249 template<
typename Delims>
259template<
typename TChar,
typename TCharTraits,
typename Delims>
278 template<
typename T,
typename TChar,
typename TCharTraits,
typename TDelimiters>
279 inline basic_ostream<TChar, TCharTraits> &
operator<<(basic_ostream<TChar, TCharTraits> & stream,
280 const ::pretty_print::print_container_helper<T, TChar, TCharTraits, TDelimiters> & helper)
288 template<
typename T,
typename TChar,
typename TCharTraits>
289 inline typename ::pretty_print::enable_if< ::pretty_print::is_container<T>::value, basic_ostream<TChar, TCharTraits>&>::type
290 operator<<(basic_ostream<TChar, TCharTraits> & stream,
const T & container)
292 return stream << ::pretty_print::print_container_helper<T, TChar, TCharTraits>(container);
296 template<
typename T1,
typename T2,
typename TChar,
typename TCharTraits>
297 inline basic_ostream<TChar, TCharTraits> &
operator<<(basic_ostream<TChar, TCharTraits> & stream,
const pair<T1, T2> & value)
300 stream << ::pretty_print::delimiters<pair<T1, T2>, TChar>::values.
prefix;
302 stream << value.first;
305 stream << ::pretty_print::delimiters<pair<T1, T2>, TChar>::values.
delimiter;
307 stream << value.second;
310 stream << ::pretty_print::delimiters<pair<T1, T2>, TChar>::values.
postfix;
327 template<
typename Tuple,
size_t N,
typename TChar,
typename TCharTraits>
330 static inline void print(::std::basic_ostream<TChar, TCharTraits> & stream,
const Tuple & value)
335 stream << delimiters<tuple_dummy_pair, TChar>::values.delimiter;
337 stream << std::tr1::get<N - 1>(value);
341 template<
typename Tuple,
typename TChar,
typename TCharTraits>
344 static inline void print(::std::basic_ostream<TChar, TCharTraits> & stream,
const Tuple & value)
346 stream << ::std::tr1::get<0>(value);
357#define TUPLE_PARAMS \
358 typename T0, typename T1, typename T2, typename T3, typename T4, \
359 typename T5, typename T6, typename T7, typename T8, typename T9
360#define TUPLE_ARGS T0, T1, T2, T3, T4, T5, T6, T7, T8, T9
365 template<
typename TChar,
typename TCharTraits, TUPLE_PARAMS>
366 inline basic_ostream<TChar, TCharTraits> &
operator<<(basic_ostream<TChar, TCharTraits> & stream,
const tr1::tuple<TUPLE_ARGS> & value)
369 stream << ::pretty_print::delimiters< ::pretty_print::tuple_dummy_pair, TChar>::values.prefix;
374 stream << ::pretty_print::delimiters< ::pretty_print::tuple_dummy_pair, TChar>::values.postfix;
398 const T *
const _array;
enable_if< has_const_iterator< T >::value, typenameT::const_iterator >::type begin(const T &c)
enable_if< has_const_iterator< T >::value, typenameT::const_iterator >::type end(const T &c)
std::pair< tuple_dummy_t, tuple_dummy_t > tuple_dummy_pair
basic_ostream< TChar, TCharTraits > & operator<<(basic_ostream< TChar, TCharTraits > &stream, const ::pretty_print::print_container_helper< T, TChar, TCharTraits, TDelimiters > &helper)
pretty_print::array_wrapper_n< T > pretty_print_array(const T *const a, size_t n)
std::basic_ostream< TChar, TCharTraits > & operator<<(std::basic_ostream< TChar, TCharTraits > &s, const pretty_print::custom_delims< Delims > &p)
array_wrapper_n(const T *const a, size_t n)
const_iterator end() const
const_iterator begin() const
virtual::std::wostream & stream(::std::wostream &)=0
virtual::std::ostream & stream(::std::ostream &)=0
virtual ~custom_delims_base()
::std::wostream & stream(::std::wostream &s)
custom_delims_wrapper(const T &t_)
::std::ostream & stream(::std::ostream &s)
custom_delims(const Container &c)
custom_delims_base * base
static const delimiters_values< char > values
static const delimiters_values< wchar_t > values
static const delimiters_values< char > values
static const delimiters_values< wchar_t > values
static const delimiters_values< char > values
static const delimiters_values< wchar_t > values
static const delimiters_values< char > values
static const delimiters_values< wchar_t > values
static const delimiters_values< wchar_t > values
static const delimiters_values< char > values
static const delimiters_values< char > values
static const delimiters_values< wchar_t > values
delimiters_values< TChar > type
TType::const_iterator iter
static bool const end_value
static char(& f(ChT< iter(Fallback::*)() const, &C::begin > *))[1]
conditional< has_const_iterator< T >::value, T, Dummy >::type TType
static char(& g(ChT< iter(Fallback::*)() const, &C::end > *))[1]
static bool const beg_value
static void print(::std::basic_ostream< TChar, TCharTraits > &stream, const Tuple &value)
static void print(::std::basic_ostream< TChar, TCharTraits > &stream, const Tuple &value)
TDelimiters delimiters_type
get_iterator< T >::iter TIter
std::basic_ostream< TChar, TCharTraits > ostream_type
void operator()(ostream_type &stream) const
print_container_helper(const T &container)