Testing <type_traits>
Jonathan Wakely
jwakely@redhat.com
Fri Oct 7 11:48:00 GMT 2016
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.
More information about the Libstdc++
mailing list