This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Testing <type_traits>


Most type traits have a requirements/typedefs.cc test like this:

#include <type_traits>

void test01()
{
 // Check for required typedefs
 typedef std::has_virtual_destructor<int>	test_type;
 typedef test_type::value_type			value_type;
 typedef test_type::type			type;
 typedef test_type::type::value_type		type_value_type;
 typedef test_type::type::type			type_type;
}

Wouldn't it be better to do something like this instead?

 typedef std::has_virtual_destructor<int>       test_type;
 static_assert( std::is_same<test_type::value_type, bool>::value, "" );
 typedef integral_constant<bool, test_type()()> bool_type;
 static_assert( std::is_same<test_type::type, bool_type>::value, "");

We should be checking that ::type is bool_constant, and if we do that
then we don't need to bother testing type::type and type::value_type.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]