pointer_traits_difference_type_test.cpp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. Copyright 2017 Glen Joseph Fernandes
  3. (glenjofe@gmail.com)
  4. Distributed under the Boost Software License, Version 1.0.
  5. (http://www.boost.org/LICENSE_1_0.txt)
  6. */
  7. #include <boost/core/pointer_traits.hpp>
  8. #include <boost/core/is_same.hpp>
  9. #include <boost/core/lightweight_test_trait.hpp>
  10. template<class T>
  11. struct P { };
  12. template<class T>
  13. struct E {
  14. typedef long difference_type;
  15. };
  16. int main()
  17. {
  18. BOOST_TEST_TRAIT_TRUE((boost::core::is_same<std::ptrdiff_t,
  19. boost::pointer_traits<int*>::difference_type>));
  20. BOOST_TEST_TRAIT_TRUE((boost::core::is_same<std::ptrdiff_t,
  21. boost::pointer_traits<P<int> >::difference_type>));
  22. BOOST_TEST_TRAIT_TRUE((boost::core::is_same<long,
  23. boost::pointer_traits<E<int> >::difference_type>));
  24. BOOST_TEST_TRAIT_TRUE((boost::core::is_same<std::ptrdiff_t,
  25. boost::pointer_traits<void*>::difference_type>));
  26. BOOST_TEST_TRAIT_TRUE((boost::core::is_same<std::ptrdiff_t,
  27. boost::pointer_traits<P<void> >::difference_type>));
  28. BOOST_TEST_TRAIT_TRUE((boost::core::is_same<long,
  29. boost::pointer_traits<E<void> >::difference_type>));
  30. BOOST_TEST_TRAIT_TRUE((boost::core::is_same<std::ptrdiff_t,
  31. boost::pointer_traits<const int*>::difference_type>));
  32. BOOST_TEST_TRAIT_TRUE((boost::core::is_same<std::ptrdiff_t,
  33. boost::pointer_traits<P<const int> >::difference_type>));
  34. BOOST_TEST_TRAIT_TRUE((boost::core::is_same<long,
  35. boost::pointer_traits<E<const int> >::difference_type>));
  36. return boost::report_errors();
  37. }