Added true_type and false_type to aid user-defined specialisations.

[SVN r21269]
This commit is contained in:
John Maddock
2003-12-15 12:01:53 +00:00
parent 8aaa85b7c3
commit b55dc5cc24
3 changed files with 80 additions and 2 deletions
+2
View File
@@ -84,8 +84,10 @@ test-suite type_traits :
[ type-traits-run tricky_is_enum_test.cpp ]
[ type-traits-run tricky_partial_spec_test.cpp ]
[ type-traits-run type_with_alignment_test.cpp ]
[ type-traits-run udt_specialisations.cpp ]
; # type traits suite
+43
View File
@@ -0,0 +1,43 @@
#include "test.hpp"
#include "check_integral_constant.hpp"
#ifdef TEST_STD
# include <type_traits>
#else
# include <boost/type_traits/is_pod.hpp>
# include <boost/type_traits/is_class.hpp>
# include <boost/type_traits/is_union.hpp>
#endif
struct my_pod{};
struct my_union
{
char c;
int i;
};
namespace tt
{
template<>
struct is_pod<my_pod>
: public true_type{};
template<>
struct is_pod<my_union>
: public true_type{};
template<>
struct is_union<my_union>
: public true_type{};
template<>
struct is_class<my_union>
: public false_type{};
}
TT_TEST_BEGIN(is_pod)
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<my_pod>::value, true);
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<my_union>::value, true);
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_union<my_union>::value, true);
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_class<my_union>::value, false);
TT_TEST_END