integer_traits_include_test.cpp 955 B

12345678910111213141516171819202122232425262728293031323334353637
  1. // Copyright John Maddock 2009.
  2. // Distributed under the Boost
  3. // 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. #include <boost/integer_traits.hpp> // must be the only #include!
  6. template <class T>
  7. void check_numeric_limits_derived(const std::numeric_limits<T>&){}
  8. template <class T>
  9. void check()
  10. {
  11. typedef boost::integer_traits<T> traits;
  12. check_numeric_limits_derived(traits());
  13. bool b = traits::is_integral;
  14. (void)b;
  15. T v = traits::const_min + traits::const_max;
  16. (void)v;
  17. }
  18. int main()
  19. {
  20. check<signed char>();
  21. check<unsigned char>();
  22. check<char>();
  23. check<short>();
  24. check<unsigned short>();
  25. check<int>();
  26. check<unsigned int>();
  27. check<signed long>();
  28. check<unsigned long>();
  29. #if !defined(BOOST_NO_INTEGRAL_INT64_T) && defined(BOOST_HAS_LONG_LONG)
  30. check<boost::long_long_type>();
  31. check<boost::ulong_long_type>();
  32. #endif
  33. }