forked from boostorg/core
Print type with cvref qualifiers
This commit is contained in:
@@ -13,6 +13,9 @@
|
||||
//
|
||||
// Copyright 2014 Peter Dimov
|
||||
//
|
||||
// Copyright 2019 Glen Joseph Fernandes
|
||||
// (glenjofe@gmail.com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
@@ -20,6 +23,7 @@
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/core/typeinfo.hpp>
|
||||
#include <boost/core/is_same.hpp>
|
||||
#include <boost/config.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
@@ -27,6 +31,50 @@ namespace boost
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template<class, int = 0> struct test_print { };
|
||||
|
||||
template<class T> inline std::ostream& operator<<(std::ostream& o, test_print<T, 2>)
|
||||
{
|
||||
return o << boost::core::demangled_name(BOOST_CORE_TYPEID(T));
|
||||
}
|
||||
|
||||
template<class T> inline std::ostream& operator<<(std::ostream& o, test_print<T, 1>)
|
||||
{
|
||||
return o << test_print<T, 2>();
|
||||
}
|
||||
|
||||
template<class T> inline std::ostream& operator<<(std::ostream& o, test_print<const T, 1>)
|
||||
{
|
||||
return o << test_print<T, 2>() << " const";
|
||||
}
|
||||
|
||||
template<class T> inline std::ostream& operator<<(std::ostream& o, test_print<volatile T, 1>)
|
||||
{
|
||||
return o << test_print<T, 2>() << " volatile";
|
||||
}
|
||||
|
||||
template<class T> inline std::ostream& operator<<(std::ostream& o, test_print<const volatile T, 1>)
|
||||
{
|
||||
return o << test_print<T, 2>() << " const volatile";
|
||||
}
|
||||
|
||||
template<class T> inline std::ostream& operator<<(std::ostream& o, test_print<T>)
|
||||
{
|
||||
return o << test_print<T, 1>();
|
||||
}
|
||||
|
||||
template<class T> inline std::ostream& operator<<(std::ostream& o, test_print<T&>)
|
||||
{
|
||||
return o << test_print<T, 1>() << " &";
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
template<class T> inline std::ostream& operator<<(std::ostream& o, test_print<T&&>)
|
||||
{
|
||||
return o << test_print<T, 1>() << " &&";
|
||||
}
|
||||
#endif
|
||||
|
||||
template< class T > inline void test_trait_impl( char const * trait, void (*)( T ),
|
||||
bool expected, char const * file, int line, char const * function )
|
||||
{
|
||||
@@ -64,8 +112,8 @@ template<class T1, class T2> inline void test_trait_same_impl( char const * type
|
||||
BOOST_LIGHTWEIGHT_TEST_OSTREAM
|
||||
<< file << "(" << line << "): test 'is_same<" << types << ">'"
|
||||
<< " failed in function '" << function
|
||||
<< "' ('" << boost::core::demangled_name( BOOST_CORE_TYPEID(T1) )
|
||||
<< "' != '" << boost::core::demangled_name( BOOST_CORE_TYPEID(T2) ) << "')"
|
||||
<< "' ('" << test_print<T1>()
|
||||
<< "' != '" << test_print<T2>() << "')"
|
||||
<< std::endl;
|
||||
|
||||
++test_results().errors();
|
||||
|
||||
Reference in New Issue
Block a user