udt_specialisations.cpp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // (C) Copyright John Maddock 2004.
  2. // Use, modification and distribution are subject to the
  3. // Boost Software License, Version 1.0. (See accompanying file
  4. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. #ifdef TEST_STD
  6. # include <type_traits>
  7. #else
  8. # include <boost/type_traits/is_pod.hpp>
  9. # include <boost/type_traits/is_class.hpp>
  10. # include <boost/type_traits/is_union.hpp>
  11. #endif
  12. #include "test.hpp"
  13. #include "check_integral_constant.hpp"
  14. struct my_pod{};
  15. struct my_union
  16. {
  17. char c;
  18. int i;
  19. };
  20. namespace tt
  21. {
  22. template<>
  23. struct is_pod<my_pod>
  24. : public mpl::true_{};
  25. template<>
  26. struct is_pod<my_union>
  27. : public mpl::true_{};
  28. template<>
  29. struct is_union<my_union>
  30. : public mpl::true_{};
  31. template<>
  32. struct is_class<my_union>
  33. : public mpl::false_{};
  34. }
  35. TT_TEST_BEGIN(is_pod)
  36. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<my_pod>::value, true);
  37. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<my_union>::value, true);
  38. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_union<my_union>::value, true);
  39. BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_class<my_union>::value, false);
  40. TT_TEST_END