1 // (C) Copyright David Abrahams 2002.
2 // (C) Copyright Jeremy Siek 2002.
3 // (C) Copyright Thomas Witt 2002.
4 // Distributed under 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)
7 #ifndef BOOST_ITERATOR_FACADE_23022003THW_HPP
8 #define BOOST_ITERATOR_FACADE_23022003THW_HPP
10 #include <boost/config.hpp>
11 #include <boost/iterator.hpp>
12 #include <boost/iterator/interoperable.hpp>
13 #include <boost/iterator/iterator_traits.hpp>
14 #include <boost/iterator/iterator_categories.hpp>
16 #include <boost/iterator/detail/facade_iterator_category.hpp>
17 #include <boost/iterator/detail/enable_if.hpp>
19 #include <boost/static_assert.hpp>
20 #include <boost/utility/addressof.hpp>
22 #include <boost/type_traits/is_same.hpp>
23 #include <boost/type_traits/add_const.hpp>
24 #include <boost/type_traits/add_pointer.hpp>
25 #include <boost/type_traits/add_lvalue_reference.hpp>
26 #include <boost/type_traits/remove_const.hpp>
27 #include <boost/type_traits/remove_reference.hpp>
28 #include <boost/type_traits/is_convertible.hpp>
29 #include <boost/type_traits/is_pod.hpp>
31 #include <boost/mpl/eval_if.hpp>
32 #include <boost/mpl/if.hpp>
33 #include <boost/mpl/or.hpp>
34 #include <boost/mpl/and.hpp>
35 #include <boost/mpl/not.hpp>
36 #include <boost/mpl/always.hpp>
37 #include <boost/mpl/apply.hpp>
38 #include <boost/mpl/identity.hpp>
40 #include <boost/iterator/detail/config_def.hpp> // this goes last
45 // This forward declaration is required for the friend declaration
46 // in iterator_core_access
47 template <class I, class V, class TC, class R, class D> class iterator_facade;
51 // A binary metafunction class that always returns bool. VC6
52 // ICEs on mpl::always<bool>, probably because of the default
56 template <class T, class U>
63 // The type trait checks if the category or traversal is at least as advanced as the specified required traversal
64 template< typename CategoryOrTraversal, typename Required >
65 struct is_traversal_at_least :
66 public boost::is_convertible< typename iterator_category_to_traversal< CategoryOrTraversal >::type, Required >
70 // enable if for use in operator implementation.
77 struct enable_if_interoperable :
78 public boost::iterators::enable_if<
79 is_interoperable< Facade1, Facade2 >
85 // enable if for use in implementation of operators specific for random access traversal.
92 struct enable_if_interoperable_and_random_access_traversal :
93 public boost::iterators::enable_if<
95 is_interoperable< Facade1, Facade2 >
96 , is_traversal_at_least< typename iterator_category< Facade1 >::type, random_access_traversal_tag >
97 , is_traversal_at_least< typename iterator_category< Facade2 >::type, random_access_traversal_tag >
104 // Generates associated types for an iterator_facade with the
109 , class CategoryOrTraversal
113 struct iterator_facade_types
115 typedef typename facade_iterator_category<
116 CategoryOrTraversal, ValueParam, Reference
117 >::type iterator_category;
119 typedef typename remove_const<ValueParam>::type value_type;
121 // Not the real associated pointer type
122 typedef typename mpl::eval_if<
123 boost::iterators::detail::iterator_writability_disabled<ValueParam,Reference>
124 , add_pointer<const value_type>
125 , add_pointer<value_type>
128 # if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) \
129 && (BOOST_WORKAROUND(_STLPORT_VERSION, BOOST_TESTED_AT(0x452)) \
130 || BOOST_WORKAROUND(BOOST_DINKUMWARE_STDLIB, BOOST_TESTED_AT(310))) \
131 || BOOST_WORKAROUND(BOOST_RWSTD_VER, BOOST_TESTED_AT(0x20101)) \
132 || BOOST_WORKAROUND(BOOST_DINKUMWARE_STDLIB, <= 310)
134 // To interoperate with some broken library/compiler
135 // combinations, user-defined iterators must be derived from
136 // std::iterator. It is possible to implement a standard
137 // library for broken compilers without this limitation.
138 # define BOOST_ITERATOR_FACADE_NEEDS_ITERATOR_BASE 1
141 iterator<iterator_category, value_type, Difference, pointer, Reference>
146 // iterators whose dereference operators reference the same value
147 // for all iterators into the same sequence (like many input
148 // iterators) need help with their postfix ++: the referenced
149 // value must be read and stored away before the increment occurs
150 // so that *a++ yields the originally referenced element and not
152 template <class Iterator>
153 class postfix_increment_proxy
155 typedef typename iterator_value<Iterator>::type value_type;
157 explicit postfix_increment_proxy(Iterator const& x)
161 // Returning a mutable reference allows nonsense like
162 // (*r++).mutate(), but it imposes fewer assumptions about the
163 // behavior of the value_type. In particular, recall that
164 // (*r).mutate() is legal if operator* returns by value.
168 return this->stored_value;
171 mutable value_type stored_value;
175 // In general, we can't determine that such an iterator isn't
176 // writable -- we also need to store a copy of the old iterator so
177 // that it can be written into.
178 template <class Iterator>
179 class writable_postfix_increment_proxy
181 typedef typename iterator_value<Iterator>::type value_type;
183 explicit writable_postfix_increment_proxy(Iterator const& x)
188 // Dereferencing must return a proxy so that both *r++ = o and
189 // value_type(*r++) can work. In this case, *r is the same as
190 // *r++, and the conversion operator below is used to ensure
192 writable_postfix_increment_proxy const&
198 // Provides readability of *r++
199 operator value_type&() const
204 // Provides writability of *r++
206 T const& operator=(T const& x) const
208 *this->stored_iterator = x;
212 // This overload just in case only non-const objects are writable
214 T& operator=(T& x) const
216 *this->stored_iterator = x;
221 operator Iterator const&() const
223 return stored_iterator;
227 mutable value_type stored_value;
228 Iterator stored_iterator;
231 # ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
233 template <class Reference, class Value>
234 struct is_non_proxy_reference_impl
239 static typename mpl::if_<
242 , Value const volatile*
246 >::type& helper(R const&);
248 BOOST_STATIC_CONSTANT(bool, value = sizeof(helper(r)) == 1);
251 template <class Reference, class Value>
252 struct is_non_proxy_reference
254 is_non_proxy_reference_impl<Reference, Value>::value
258 template <class Reference, class Value>
259 struct is_non_proxy_reference
261 typename remove_reference<Reference>::type
263 , Value const volatile*
268 // A metafunction to choose the result type of postfix ++
270 // Because the C++98 input iterator requirements say that *r++ has
271 // type T (value_type), implementations of some standard
272 // algorithms like lexicographical_compare may use constructions
277 // If *r++ returns a proxy (as required if r is writable but not
278 // multipass), this sort of expression will fail unless the proxy
279 // supports the operator<. Since there are any number of such
280 // operations, we're not going to try to support them. Therefore,
281 // even if r++ returns a proxy, *r++ will only return a proxy if
282 // *r also returns a proxy.
283 template <class Iterator, class Value, class Reference, class CategoryOrTraversal>
284 struct postfix_increment_result
287 // A proxy is only needed for readable iterators
290 // Use add_lvalue_reference to form `reference to Value` due to
291 // some (strict) C++03 compilers (e.g. `gcc -std=c++03`) reject
292 // 'reference-to-reference' in the template which described in CWG
294 // http://www.open-std.org/Jtc1/sc22/wg21/docs/cwg_defects.html#106
295 , typename add_lvalue_reference<Value const>::type
298 // No multipass iterator can have values that disappear
299 // before positions can be re-visited
302 typename iterator_category_to_traversal<CategoryOrTraversal>::type
303 , forward_traversal_tag
308 is_non_proxy_reference<Reference,Value>
309 , postfix_increment_proxy<Iterator>
310 , writable_postfix_increment_proxy<Iterator>
312 , mpl::identity<Iterator>
316 // operator->() needs special support for input iterators to strictly meet the
317 // standard's requirements. If *i is not a reference type, we must still
318 // produce an lvalue to which a pointer can be formed. We do that by
319 // returning a proxy object containing an instance of the reference object.
320 template <class Reference, class Pointer>
321 struct operator_arrow_dispatch // proxy references
325 explicit proxy(Reference const & x) : m_ref(x) {}
326 Reference* operator->() { return boost::addressof(m_ref); }
327 // This function is needed for MWCW and BCC, which won't call
328 // operator-> again automatically per 13.3.1.2 para 8
329 operator Reference*() { return boost::addressof(m_ref); }
332 typedef proxy result_type;
333 static result_type apply(Reference const & x)
335 return result_type(x);
339 template <class T, class Pointer>
340 struct operator_arrow_dispatch<T&, Pointer> // "real" references
342 typedef Pointer result_type;
343 static result_type apply(T& x)
345 return boost::addressof(x);
349 // A proxy return type for operator[], needed to deal with
350 // iterators that may invalidate referents upon destruction.
351 // Consider the temporary iterator in *(a + n)
352 template <class Iterator>
353 class operator_brackets_proxy
355 // Iterator is actually an iterator_facade, so we do not have to
356 // go through iterator_traits to access the traits.
357 typedef typename Iterator::reference reference;
358 typedef typename Iterator::value_type value_type;
361 operator_brackets_proxy(Iterator const& iter)
365 operator reference() const
370 operator_brackets_proxy& operator=(value_type const& val)
380 // A metafunction that determines whether operator[] must return a
381 // proxy, or whether it can simply return a copy of the value_type.
382 template <class ValueType, class Reference>
383 struct use_operator_brackets_proxy
386 // Really we want an is_copy_constructible trait here,
387 // but is_POD will have to suffice in the meantime.
388 boost::is_POD<ValueType>
389 , iterator_writability_disabled<ValueType,Reference>
394 template <class Iterator, class Value, class Reference>
395 struct operator_brackets_result
397 typedef typename mpl::if_<
398 use_operator_brackets_proxy<Value,Reference>
399 , operator_brackets_proxy<Iterator>
404 template <class Iterator>
405 operator_brackets_proxy<Iterator> make_operator_brackets_result(Iterator const& iter, mpl::true_)
407 return operator_brackets_proxy<Iterator>(iter);
410 template <class Iterator>
411 typename Iterator::value_type make_operator_brackets_result(Iterator const& iter, mpl::false_)
416 struct choose_difference_type
418 template <class I1, class I2>
421 # ifdef BOOST_NO_ONE_WAY_ITERATOR_INTEROP
422 iterator_difference<I1>
425 is_convertible<I2,I1>
426 , iterator_difference<I1>
427 , iterator_difference<I2>
437 , class CategoryOrTraversal
440 , bool IsBidirectionalTraversal
441 , bool IsRandomAccessTraversal
443 class iterator_facade_base;
445 } // namespace detail
448 // Macros which describe the declarations of binary operators
449 # ifdef BOOST_NO_STRICT_ITERATOR_INTEROPERABILITY
450 # define BOOST_ITERATOR_FACADE_INTEROP_HEAD_IMPL(prefix, op, result_type, enabler) \
452 class Derived1, class V1, class TC1, class Reference1, class Difference1 \
453 , class Derived2, class V2, class TC2, class Reference2, class Difference2 \
455 prefix typename mpl::apply2<result_type,Derived1,Derived2>::type \
457 iterator_facade<Derived1, V1, TC1, Reference1, Difference1> const& lhs \
458 , iterator_facade<Derived2, V2, TC2, Reference2, Difference2> const& rhs)
460 # define BOOST_ITERATOR_FACADE_INTEROP_HEAD_IMPL(prefix, op, result_type, enabler) \
462 class Derived1, class V1, class TC1, class Reference1, class Difference1 \
463 , class Derived2, class V2, class TC2, class Reference2, class Difference2 \
465 prefix typename enabler< \
467 , typename mpl::apply2<result_type,Derived1,Derived2>::type \
470 iterator_facade<Derived1, V1, TC1, Reference1, Difference1> const& lhs \
471 , iterator_facade<Derived2, V2, TC2, Reference2, Difference2> const& rhs)
474 # define BOOST_ITERATOR_FACADE_INTEROP_HEAD(prefix, op, result_type) \
475 BOOST_ITERATOR_FACADE_INTEROP_HEAD_IMPL(prefix, op, result_type, boost::iterators::detail::enable_if_interoperable)
477 # define BOOST_ITERATOR_FACADE_INTEROP_RANDOM_ACCESS_HEAD(prefix, op, result_type) \
478 BOOST_ITERATOR_FACADE_INTEROP_HEAD_IMPL(prefix, op, result_type, boost::iterators::detail::enable_if_interoperable_and_random_access_traversal)
480 # define BOOST_ITERATOR_FACADE_PLUS_HEAD(prefix,args) \
481 template <class Derived, class V, class TC, class R, class D> \
482 prefix typename boost::iterators::enable_if< \
483 boost::iterators::detail::is_traversal_at_least< TC, boost::iterators::random_access_traversal_tag >, \
485 >::type operator+ args
488 // Helper class for granting access to the iterator core interface.
490 // The simple core interface is used by iterator_facade. The core
491 // interface of a user/library defined iterator type should not be made public
492 // so that it does not clutter the public interface. Instead iterator_core_access
493 // should be made friend so that iterator_facade can access the core
494 // interface through iterator_core_access.
496 class iterator_core_access
498 # if defined(BOOST_NO_MEMBER_TEMPLATE_FRIENDS)
499 // Tasteless as this may seem, making all members public allows member templates
500 // to work in the absence of member template friends.
504 template <class I, class V, class TC, class R, class D> friend class iterator_facade;
505 template <class I, class V, class TC, class R, class D, bool IsBidirectionalTraversal, bool IsRandomAccessTraversal>
506 friend class detail::iterator_facade_base;
508 # define BOOST_ITERATOR_FACADE_RELATION(op) \
509 BOOST_ITERATOR_FACADE_INTEROP_HEAD(friend,op, boost::iterators::detail::always_bool2);
511 BOOST_ITERATOR_FACADE_RELATION(==)
512 BOOST_ITERATOR_FACADE_RELATION(!=)
514 # undef BOOST_ITERATOR_FACADE_RELATION
516 # define BOOST_ITERATOR_FACADE_RANDOM_ACCESS_RELATION(op) \
517 BOOST_ITERATOR_FACADE_INTEROP_RANDOM_ACCESS_HEAD(friend,op, boost::iterators::detail::always_bool2);
519 BOOST_ITERATOR_FACADE_RANDOM_ACCESS_RELATION(<)
520 BOOST_ITERATOR_FACADE_RANDOM_ACCESS_RELATION(>)
521 BOOST_ITERATOR_FACADE_RANDOM_ACCESS_RELATION(<=)
522 BOOST_ITERATOR_FACADE_RANDOM_ACCESS_RELATION(>=)
524 # undef BOOST_ITERATOR_FACADE_RANDOM_ACCESS_RELATION
526 BOOST_ITERATOR_FACADE_INTEROP_RANDOM_ACCESS_HEAD(
527 friend, -, boost::iterators::detail::choose_difference_type)
530 BOOST_ITERATOR_FACADE_PLUS_HEAD(
532 , (iterator_facade<Derived, V, TC, R, D> const&
533 , typename Derived::difference_type)
537 BOOST_ITERATOR_FACADE_PLUS_HEAD(
539 , (typename Derived::difference_type
540 , iterator_facade<Derived, V, TC, R, D> const&)
546 template <class Facade>
547 static typename Facade::reference dereference(Facade const& f)
549 return f.dereference();
552 template <class Facade>
553 static void increment(Facade& f)
558 template <class Facade>
559 static void decrement(Facade& f)
564 template <class Facade1, class Facade2>
565 static bool equal(Facade1 const& f1, Facade2 const& f2, mpl::true_)
570 template <class Facade1, class Facade2>
571 static bool equal(Facade1 const& f1, Facade2 const& f2, mpl::false_)
576 template <class Facade>
577 static void advance(Facade& f, typename Facade::difference_type n)
582 template <class Facade1, class Facade2>
583 static typename Facade1::difference_type distance_from(
584 Facade1 const& f1, Facade2 const& f2, mpl::true_)
586 return -f1.distance_to(f2);
589 template <class Facade1, class Facade2>
590 static typename Facade2::difference_type distance_from(
591 Facade1 const& f1, Facade2 const& f2, mpl::false_)
593 return f2.distance_to(f1);
597 // Curiously Recurring Template interface.
599 template <class I, class V, class TC, class R, class D>
600 static I& derived(iterator_facade<I,V,TC,R,D>& facade)
602 return *static_cast<I*>(&facade);
605 template <class I, class V, class TC, class R, class D>
606 static I const& derived(iterator_facade<I,V,TC,R,D> const& facade)
608 return *static_cast<I const*>(&facade);
611 // objects of this class are useless
612 BOOST_DELETED_FUNCTION(iterator_core_access())
617 // Implementation for forward traversal iterators
621 , class CategoryOrTraversal
625 class iterator_facade_base< Derived, Value, CategoryOrTraversal, Reference, Difference, false, false >
626 # ifdef BOOST_ITERATOR_FACADE_NEEDS_ITERATOR_BASE
627 : public boost::iterators::detail::iterator_facade_types<
628 Value, CategoryOrTraversal, Reference, Difference
630 # undef BOOST_ITERATOR_FACADE_NEEDS_ITERATOR_BASE
634 typedef boost::iterators::detail::iterator_facade_types<
635 Value, CategoryOrTraversal, Reference, Difference
638 typedef boost::iterators::detail::operator_arrow_dispatch<
640 , typename associated_types::pointer
641 > operator_arrow_dispatch_;
644 typedef typename associated_types::value_type value_type;
645 typedef Reference reference;
646 typedef Difference difference_type;
648 typedef typename operator_arrow_dispatch_::result_type pointer;
650 typedef typename associated_types::iterator_category iterator_category;
653 reference operator*() const
655 return iterator_core_access::dereference(this->derived());
658 pointer operator->() const
660 return operator_arrow_dispatch_::apply(*this->derived());
663 Derived& operator++()
665 iterator_core_access::increment(this->derived());
666 return this->derived();
671 // Curiously Recurring Template interface.
675 return *static_cast<Derived*>(this);
678 Derived const& derived() const
680 return *static_cast<Derived const*>(this);
684 // Implementation for bidirectional traversal iterators
688 , class CategoryOrTraversal
692 class iterator_facade_base< Derived, Value, CategoryOrTraversal, Reference, Difference, true, false > :
693 public iterator_facade_base< Derived, Value, CategoryOrTraversal, Reference, Difference, false, false >
696 Derived& operator--()
698 iterator_core_access::decrement(this->derived());
699 return this->derived();
702 Derived operator--(int)
704 Derived tmp(this->derived());
710 // Implementation for random access traversal iterators
714 , class CategoryOrTraversal
718 class iterator_facade_base< Derived, Value, CategoryOrTraversal, Reference, Difference, true, true > :
719 public iterator_facade_base< Derived, Value, CategoryOrTraversal, Reference, Difference, true, false >
722 typedef iterator_facade_base< Derived, Value, CategoryOrTraversal, Reference, Difference, true, false > base_type;
725 typedef typename base_type::reference reference;
726 typedef typename base_type::difference_type difference_type;
729 typename boost::iterators::detail::operator_brackets_result<Derived, Value, reference>::type
730 operator[](difference_type n) const
732 typedef boost::iterators::detail::use_operator_brackets_proxy<Value, Reference> use_proxy;
734 return boost::iterators::detail::make_operator_brackets_result<Derived>(
740 Derived& operator+=(difference_type n)
742 iterator_core_access::advance(this->derived(), n);
743 return this->derived();
746 Derived& operator-=(difference_type n)
748 iterator_core_access::advance(this->derived(), -n);
749 return this->derived();
752 Derived operator-(difference_type x) const
754 Derived result(this->derived());
759 } // namespace detail
762 // iterator_facade - use as a public base class for defining new
763 // standard-conforming iterators.
766 class Derived // The derived iterator type being constructed
768 , class CategoryOrTraversal
769 , class Reference = Value&
770 , class Difference = std::ptrdiff_t
772 class iterator_facade :
773 public detail::iterator_facade_base<
779 detail::is_traversal_at_least< CategoryOrTraversal, bidirectional_traversal_tag >::value,
780 detail::is_traversal_at_least< CategoryOrTraversal, random_access_traversal_tag >::value
784 // For use by derived classes
785 typedef iterator_facade<Derived,Value,CategoryOrTraversal,Reference,Difference> iterator_facade_;
788 template <class I, class V, class TC, class R, class D>
789 inline typename boost::iterators::detail::postfix_increment_result<I,V,R,TC>::type
791 iterator_facade<I,V,TC,R,D>& i
795 typename boost::iterators::detail::postfix_increment_result<I,V,R,TC>::type
796 tmp(*static_cast<I*>(&i));
805 // Comparison operator implementation. The library supplied operators
806 // enables the user to provide fully interoperable constant/mutable
807 // iterator types. I.e. the library provides all operators
808 // for all mutable/constant iterator combinations.
810 // Note though that this kind of interoperability for constant/mutable
811 // iterators is not required by the standard for container iterators.
812 // All the standard asks for is a conversion mutable -> constant.
813 // Most standard library implementations nowadays provide fully interoperable
814 // iterator implementations, but there are still heavily used implementations
815 // that do not provide them. (Actually it's even worse, they do not provide
816 // them for only a few iterators.)
818 // ?? Maybe a BOOST_ITERATOR_NO_FULL_INTEROPERABILITY macro should
819 // enable the user to turn off mixed type operators
821 // The library takes care to provide only the right operator overloads.
824 // bool operator==(Iterator, Iterator);
825 // bool operator==(ConstIterator, Iterator);
826 // bool operator==(Iterator, ConstIterator);
827 // bool operator==(ConstIterator, ConstIterator);
831 // In order to do so it uses c++ idioms that are not yet widely supported
832 // by current compiler releases. The library is designed to degrade gracefully
833 // in the face of compiler deficiencies. In general compiler
834 // deficiencies result in less strict error checking and more obscure
835 // error messages, functionality is not affected.
837 // For full operation compiler support for "Substitution Failure Is Not An Error"
838 // (aka. enable_if) and boost::is_convertible is required.
840 // The following problems occur if support is lacking.
845 // AdaptorA<Iterator1> a1;
846 // AdaptorA<Iterator2> a2;
848 // // This will result in a no such overload error in full operation
849 // // If enable_if or is_convertible is not supported
850 // // The instantiation will fail with an error hopefully indicating that
851 // // there is no operator== for Iterator1, Iterator2
852 // // The same will happen if no enable_if is used to remove
853 // // false overloads from the templated conversion constructor
859 // AdaptorA<Iterator> a;
860 // AdaptorB<Iterator> b;
862 // // This will result in a no such overload error in full operation
863 // // If enable_if is not supported the static assert used
864 // // in the operator implementation will fail.
865 // // This will accidently work if is_convertible is not supported.
871 # ifdef BOOST_NO_ONE_WAY_ITERATOR_INTEROP
872 # define BOOST_ITERATOR_CONVERTIBLE(a,b) mpl::true_()
874 # define BOOST_ITERATOR_CONVERTIBLE(a,b) is_convertible<a,b>()
877 # define BOOST_ITERATOR_FACADE_INTEROP(op, result_type, return_prefix, base_op) \
878 BOOST_ITERATOR_FACADE_INTEROP_HEAD(inline, op, result_type) \
880 /* For those compilers that do not support enable_if */ \
881 BOOST_STATIC_ASSERT(( \
882 is_interoperable< Derived1, Derived2 >::value \
884 return_prefix iterator_core_access::base_op( \
885 *static_cast<Derived1 const*>(&lhs) \
886 , *static_cast<Derived2 const*>(&rhs) \
887 , BOOST_ITERATOR_CONVERTIBLE(Derived2,Derived1) \
891 # define BOOST_ITERATOR_FACADE_RELATION(op, return_prefix, base_op) \
892 BOOST_ITERATOR_FACADE_INTEROP( \
894 , boost::iterators::detail::always_bool2 \
899 BOOST_ITERATOR_FACADE_RELATION(==, return, equal)
900 BOOST_ITERATOR_FACADE_RELATION(!=, return !, equal)
902 # undef BOOST_ITERATOR_FACADE_RELATION
905 # define BOOST_ITERATOR_FACADE_INTEROP_RANDOM_ACCESS(op, result_type, return_prefix, base_op) \
906 BOOST_ITERATOR_FACADE_INTEROP_RANDOM_ACCESS_HEAD(inline, op, result_type) \
908 /* For those compilers that do not support enable_if */ \
909 BOOST_STATIC_ASSERT(( \
910 is_interoperable< Derived1, Derived2 >::value && \
911 boost::iterators::detail::is_traversal_at_least< typename iterator_category< Derived1 >::type, random_access_traversal_tag >::value && \
912 boost::iterators::detail::is_traversal_at_least< typename iterator_category< Derived2 >::type, random_access_traversal_tag >::value \
914 return_prefix iterator_core_access::base_op( \
915 *static_cast<Derived1 const*>(&lhs) \
916 , *static_cast<Derived2 const*>(&rhs) \
917 , BOOST_ITERATOR_CONVERTIBLE(Derived2,Derived1) \
921 # define BOOST_ITERATOR_FACADE_RANDOM_ACCESS_RELATION(op, return_prefix, base_op) \
922 BOOST_ITERATOR_FACADE_INTEROP_RANDOM_ACCESS( \
924 , boost::iterators::detail::always_bool2 \
929 BOOST_ITERATOR_FACADE_RANDOM_ACCESS_RELATION(<, return 0 >, distance_from)
930 BOOST_ITERATOR_FACADE_RANDOM_ACCESS_RELATION(>, return 0 <, distance_from)
931 BOOST_ITERATOR_FACADE_RANDOM_ACCESS_RELATION(<=, return 0 >=, distance_from)
932 BOOST_ITERATOR_FACADE_RANDOM_ACCESS_RELATION(>=, return 0 <=, distance_from)
934 # undef BOOST_ITERATOR_FACADE_RANDOM_ACCESS_RELATION
936 // operator- requires an additional part in the static assertion
937 BOOST_ITERATOR_FACADE_INTEROP_RANDOM_ACCESS(
939 , boost::iterators::detail::choose_difference_type
944 # undef BOOST_ITERATOR_FACADE_INTEROP
945 # undef BOOST_ITERATOR_FACADE_INTEROP_RANDOM_ACCESS
947 # define BOOST_ITERATOR_FACADE_PLUS(args) \
948 BOOST_ITERATOR_FACADE_PLUS_HEAD(inline, args) \
950 Derived tmp(static_cast<Derived const&>(i)); \
954 BOOST_ITERATOR_FACADE_PLUS((
955 iterator_facade<Derived, V, TC, R, D> const& i
956 , typename Derived::difference_type n
959 BOOST_ITERATOR_FACADE_PLUS((
960 typename Derived::difference_type n
961 , iterator_facade<Derived, V, TC, R, D> const& i
964 # undef BOOST_ITERATOR_FACADE_PLUS
965 # undef BOOST_ITERATOR_FACADE_PLUS_HEAD
967 # undef BOOST_ITERATOR_FACADE_INTEROP_HEAD
968 # undef BOOST_ITERATOR_FACADE_INTEROP_RANDOM_ACCESS_HEAD
969 # undef BOOST_ITERATOR_FACADE_INTEROP_HEAD_IMPL
971 } // namespace iterators
973 using iterators::iterator_core_access;
974 using iterators::iterator_facade;
978 #include <boost/iterator/detail/config_undef.hpp>
980 #endif // BOOST_ITERATOR_FACADE_23022003THW_HPP