1 // Boost.Range library concept checks
3 // Copyright Daniel Walker 2006. Use, modification and distribution
4 // are subject to the Boost Software License, Version 1.0. (See
5 // accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt)
8 // For more information, see http://www.boost.org/libs/range/
11 #ifndef BOOST_RANGE_CONCEPTS_HPP
12 #define BOOST_RANGE_CONCEPTS_HPP
14 #include <boost/concept_check.hpp>
15 #include <boost/iterator/iterator_concepts.hpp>
16 #include <boost/range/begin.hpp>
17 #include <boost/range/end.hpp>
21 * \brief Concept checks for the Boost Range library.
23 * The structures in this file may be used in conjunction with the
24 * Boost Concept Check library to insure that the type of a function
25 * parameter is compatible with a range concept. If not, a meaningful
26 * compile time error is generated. Checks are provided for the range
27 * concepts related to iterator traversal categories. For example, the
28 * following line checks that the type T models the ForwardRange
32 * function_requires<ForwardRangeConcept<T> >();
35 * An additional concept check is required for the value access
36 * property of the range. For example to check for a
37 * ForwardReadableRange, the following code is required.
40 * function_requires<ForwardRangeConcept<T> >();
42 * ReadableIteratorConcept<
43 * typename range_iterator<T>::type
48 * \see http://www.boost.org/libs/range/doc/range.html for details
49 * about range concepts.
50 * \see http://www.boost.org/libs/iterator/doc/iterator_concepts.html
51 * for details about iterator concepts.
52 * \see http://www.boost.org/libs/concept_check/concept_check.htm for
53 * details about concept checks.
58 //! Check if a type T models the SinglePassRange range concept.
60 struct SinglePassRangeConcept
62 typedef typename range_iterator
<T
const>::type range_const_iterator
;
63 typedef typename range_iterator
<T
>::type range_iterator
;
68 boost_concepts::SinglePassIteratorConcept
<
77 void const_constraints(const T
& a
)
84 range_const_iterator ci
;
87 //! Check if a type T models the ForwardRange range concept.
89 struct ForwardRangeConcept
94 SinglePassRangeConcept
<T
>
97 boost_concepts::ForwardTraversalConcept
<
98 typename range_iterator
<T
>::type
104 //! Check if a type T models the BidirectionalRange range concept.
106 struct BidirectionalRangeConcept
111 ForwardRangeConcept
<T
>
114 boost_concepts::BidirectionalTraversalConcept
<
115 typename range_iterator
<T
>::type
121 //! Check if a type T models the RandomAccessRange range concept.
123 struct RandomAccessRangeConcept
128 BidirectionalRangeConcept
<T
>
131 boost_concepts::RandomAccessTraversalConcept
<
132 typename range_iterator
<T
>::type
140 #endif // BOOST_RANGE_CONCEPTS_HPP