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
11#define BOOST_ALLOW_DEPRECATED_HEADERS
12#define _SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING
13
14#include <boost/config.hpp>
15
16// std::iterator template is deprecated in C++17. Some standard libraries emit warnings
17// that cannot be easily suppressed, so disable the tests in C++17 onwards.
18#if BOOST_CXX_VERSION < 201703
19
20#include <boost/iterator.hpp>
21#include <boost/core/lightweight_test_trait.hpp>
22#include <boost/type_traits/is_same.hpp>
23
24/*
25
26template< class Category, class T,
27 class Distance = ptrdiff_t,
28 class Pointer = T*,
29 class Reference = T&>
30struct iterator
31{
32 typedef T value_type;
33 typedef Distance difference_type;
34 typedef Pointer pointer;
35 typedef Reference reference;
36 typedef Category iterator_category;
37};
38
39*/
40
41struct C
42{
43};
44
45struct T
46{
47};
48
49struct D
50{
51};
52
53struct P
54{
55};
56
57struct R
58{
59};
60
61int main()
62{
63 using boost::is_same;
64
65 BOOST_TEST_TRAIT_TRUE((is_same<boost::iterator<C,T,D,P,R>::iterator_category,C>));
66 BOOST_TEST_TRAIT_TRUE((is_same<boost::iterator<C,T,D,P,R>::value_type,T>));
67 BOOST_TEST_TRAIT_TRUE((is_same<boost::iterator<C,T,D,P,R>::difference_type,D>));
68 BOOST_TEST_TRAIT_TRUE((is_same<boost::iterator<C,T,D,P,R>::pointer,P>));
69 BOOST_TEST_TRAIT_TRUE((is_same<boost::iterator<C,T,D,P,R>::reference,R>));
70
71 BOOST_TEST_TRAIT_TRUE((is_same<boost::iterator<C,T>::iterator_category,C>));
72 BOOST_TEST_TRAIT_TRUE((is_same<boost::iterator<C,T>::value_type,T>));
73 BOOST_TEST_TRAIT_TRUE((is_same<boost::iterator<C,T>::difference_type,std::ptrdiff_t>));
74 BOOST_TEST_TRAIT_TRUE((is_same<boost::iterator<C,T>::pointer,T*>));
75 BOOST_TEST_TRAIT_TRUE((is_same<boost::iterator<C,T>::reference,T&>));
76
77 return boost::report_errors();
78}
79
80#else // BOOST_CXX_VERSION < 201703
81
82int main()
83{
84}
85
86#endif // BOOST_CXX_VERSION < 201703
87

source code of boost/libs/core/test/iterator_test.cpp