diff options
author | DongHun Kwak <dh0128.kwak@samsung.com> | 2017-09-13 11:08:07 +0900 |
---|---|---|
committer | DongHun Kwak <dh0128.kwak@samsung.com> | 2017-09-13 11:09:00 +0900 |
commit | b5c87084afaef42b2d058f68091be31988a6a874 (patch) | |
tree | adef9a65870a41181687e11d57fdf98e7629de3c /boost/test/tools/detail/print_helper.hpp | |
parent | 34bd32e225e2a8a94104489b31c42e5801cc1f4a (diff) | |
download | boost-b5c87084afaef42b2d058f68091be31988a6a874.tar.gz boost-b5c87084afaef42b2d058f68091be31988a6a874.tar.bz2 boost-b5c87084afaef42b2d058f68091be31988a6a874.zip |
Imported Upstream version 1.64.0upstream/1.64.0
Change-Id: Id9212edd016dd55f21172c427aa7894d1d24148b
Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
Diffstat (limited to 'boost/test/tools/detail/print_helper.hpp')
-rw-r--r-- | boost/test/tools/detail/print_helper.hpp | 54 |
1 files changed, 46 insertions, 8 deletions
diff --git a/boost/test/tools/detail/print_helper.hpp b/boost/test/tools/detail/print_helper.hpp index 39ab707f36..1e4dd6e3c0 100644 --- a/boost/test/tools/detail/print_helper.hpp +++ b/boost/test/tools/detail/print_helper.hpp @@ -30,6 +30,10 @@ #include <limits> +#if !defined(BOOST_NO_CXX11_NULLPTR) +#include <cstddef> +#endif + #include <boost/test/detail/suppress_warnings.hpp> //____________________________________________________________________________// @@ -39,21 +43,51 @@ namespace test_tools { namespace tt_detail { // ************************************************************************** // +// ************** boost_test_print_type ************** // +// ************************************************************************** // + + namespace impl { + template <class T> + std::ostream& boost_test_print_type(std::ostream& ostr, T const& t) { + BOOST_STATIC_ASSERT_MSG( (boost::has_left_shift<std::ostream,T>::value), + "Type has to implement operator<< to be printable"); + ostr << t; + return ostr; + } + + struct boost_test_print_type_impl { + template <class R> + std::ostream& operator()(std::ostream& ostr, R const& r) const { + return boost_test_print_type(ostr, r); + } + }; + } + + // To avoid ODR violations, see N4381 + template <class T> struct static_const { static const T value; }; + template <class T> const T static_const<T>::value = T(); + + namespace { + static const impl::boost_test_print_type_impl& boost_test_print_type = + static_const<impl::boost_test_print_type_impl>::value; + } + + +// ************************************************************************** // // ************** print_log_value ************** // // ************************************************************************** // template<typename T> struct print_log_value { - BOOST_STATIC_ASSERT_MSG( (boost::has_left_shift<std::ostream,T>::value), - "Type has to implement operator<< to be printable"); - void operator()( std::ostream& ostr, T const& t ) { typedef typename mpl::or_<is_array<T>,is_function<T>,is_abstract<T> >::type cant_use_nl; std::streamsize old_precision = set_precision( ostr, cant_use_nl() ); - ostr << t; + //ostr << t; + using boost::test_tools::tt_detail::boost_test_print_type; + boost_test_print_type(ostr, t); if( old_precision != (std::streamsize)-1 ) ostr.precision( old_precision ); @@ -99,10 +133,7 @@ struct print_log_value< T[N] > { template<> struct BOOST_TEST_DECL print_log_value<bool> { - void operator()( std::ostream& ostr, bool t ) - { - ostr << std::boolalpha << t; - } + void operator()( std::ostream& ostr, bool t ); }; //____________________________________________________________________________// @@ -133,6 +164,13 @@ struct BOOST_TEST_DECL print_log_value<wchar_t const*> { void operator()( std::ostream& ostr, wchar_t const* t ); }; +#if !defined(BOOST_NO_CXX11_NULLPTR) +template<> +struct BOOST_TEST_DECL print_log_value<std::nullptr_t> { + void operator()( std::ostream& ostr, std::nullptr_t t ); +}; +#endif + //____________________________________________________________________________// // ************************************************************************** // |