iterator_test.cpp 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. //
  2. // Test for boost/iterator.hpp
  3. //
  4. // Copyright 2014 Peter Dimov
  5. //
  6. // Distributed under the Boost Software License, Version 1.0.
  7. // See accompanying file LICENSE_1_0.txt or copy at
  8. // http://www.boost.org/LICENSE_1_0.txt
  9. //
  10. #include <boost/iterator.hpp>
  11. #include <boost/core/is_same.hpp>
  12. #include <boost/core/lightweight_test_trait.hpp>
  13. /*
  14. template< class Category, class T,
  15. class Distance = ptrdiff_t,
  16. class Pointer = T*,
  17. class Reference = T&>
  18. struct iterator
  19. {
  20. typedef T value_type;
  21. typedef Distance difference_type;
  22. typedef Pointer pointer;
  23. typedef Reference reference;
  24. typedef Category iterator_category;
  25. };
  26. */
  27. struct C
  28. {
  29. };
  30. struct T
  31. {
  32. };
  33. struct D
  34. {
  35. };
  36. struct P
  37. {
  38. };
  39. struct R
  40. {
  41. };
  42. int main()
  43. {
  44. using boost::core::is_same;
  45. BOOST_TEST_TRAIT_TRUE((is_same<boost::iterator<C,T,D,P,R>::iterator_category,C>));
  46. BOOST_TEST_TRAIT_TRUE((is_same<boost::iterator<C,T,D,P,R>::value_type,T>));
  47. BOOST_TEST_TRAIT_TRUE((is_same<boost::iterator<C,T,D,P,R>::difference_type,D>));
  48. BOOST_TEST_TRAIT_TRUE((is_same<boost::iterator<C,T,D,P,R>::pointer,P>));
  49. BOOST_TEST_TRAIT_TRUE((is_same<boost::iterator<C,T,D,P,R>::reference,R>));
  50. BOOST_TEST_TRAIT_TRUE((is_same<boost::iterator<C,T>::iterator_category,C>));
  51. BOOST_TEST_TRAIT_TRUE((is_same<boost::iterator<C,T>::value_type,T>));
  52. BOOST_TEST_TRAIT_TRUE((is_same<boost::iterator<C,T>::difference_type,std::ptrdiff_t>));
  53. BOOST_TEST_TRAIT_TRUE((is_same<boost::iterator<C,T>::pointer,T*>));
  54. BOOST_TEST_TRAIT_TRUE((is_same<boost::iterator<C,T>::reference,T&>));
  55. return boost::report_errors();
  56. }