fix pretty printer for recursive types

This commit is contained in:
Johannes Kapfhammer 2019-10-06 18:37:37 +02:00
parent 310d119ffb
commit 4d25fc25c4
5 changed files with 396 additions and 388 deletions

View file

@ -3,7 +3,7 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// pretty printing with c++
// pretty pretty_printing with c++
//
#ifndef SOI_PRETTY
@ -11,14 +11,7 @@
#include "prettyprint.hpp"
namespace soi_h {
template<typename T, typename TChar, typename TCharTraits>
inline typename std::enable_if< ::pretty_print::is_container<T>::value,
std::basic_ostream<TChar, TCharTraits> &>::type
pretty_print(std::basic_ostream<TChar, TCharTraits> & stream, const T & container) {
return stream << ::pretty_print::print_container_helper<T, TChar, TCharTraits>(container);
}
namespace soi {
template<typename TChar, typename TCharTraits>
std::basic_ostream<TChar, TCharTraits> &
@ -65,12 +58,18 @@ pretty_print(std::basic_ostream<TChar, TCharTraits> & stream, char c) {
}
template<typename T, typename TChar, typename TCharTraits>
inline typename std::enable_if< !::pretty_print::is_container<T>::value,
inline typename std::enable_if< !::soi::is_container<T>::value,
std::basic_ostream<TChar, TCharTraits> &>::type
pretty_print(std::basic_ostream<TChar, TCharTraits> & stream, const T& x) {
return stream << x;
}
template<typename T, typename TChar, typename TCharTraits>
std::basic_ostream<TChar, TCharTraits> &
print(std::basic_ostream<TChar, TCharTraits> & stream, const T& x) {
return pretty_print(stream, x);
}
}
#endif // SOI_PRETTY