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/interoperable.hpp>
12 #include <boost/iterator/iterator_traits.hpp>
13 #include <boost/iterator/iterator_categories.hpp>
15 #include <boost/iterator/detail/facade_iterator_category.hpp>
16 #include <boost/iterator/detail/enable_if.hpp>
18 #include <boost/static_assert.hpp>
19 #include <boost/core/addressof.hpp>
21 #include <boost/type_traits/is_same.hpp>
22 #include <boost/type_traits/add_const.hpp>
23 #include <boost/type_traits/add_pointer.hpp>
24 #include <boost/type_traits/add_lvalue_reference.hpp>
25 #include <boost/type_traits/remove_const.hpp>
26 #include <boost/type_traits/remove_reference.hpp>
27 #include <boost/type_traits/is_convertible.hpp>
28 #include <boost/type_traits/is_pod.hpp>
30 #include <boost/mpl/eval_if.hpp>
31 #include <boost/mpl/if.hpp>
32 #include <boost/mpl/or.hpp>
33 #include <boost/mpl/and.hpp>
34 #include <boost/mpl/not.hpp>
35 #include <boost/mpl/always.hpp>
36 #include <boost/mpl/apply.hpp>
37 #include <boost/mpl/identity.hpp>
41 #include <boost/iterator/detail/config_def.hpp> // this goes last
46 // This forward declaration is required for the friend declaration
47 // in iterator_core_access
48 template <class I, class V, class TC, class R, class D> class iterator_facade;
52 // A binary metafunction class that always returns bool. VC6
53 // ICEs on mpl::always<bool>, probably because of the default
57 template <class T, class U>
64 // The type trait checks if the category or traversal is at least as advanced as the specified required traversal
65 template< typename CategoryOrTraversal, typename Required >
66 struct is_traversal_at_least :
67 public boost::is_convertible< typename iterator_category_to_traversal< CategoryOrTraversal >::type, Required >
71 // enable if for use in operator implementation.
78 struct enable_if_interoperable :
79 public boost::iterators::enable_if<
80 is_interoperable< Facade1, Facade2 >
86 // enable if for use in implementation of operators specific for random access traversal.
93 struct enable_if_interoperable_and_random_access_traversal :
94 public boost::iterators::enable_if<
96 is_interoperable< Facade1, Facade2 >
97 , is_traversal_at_least< typename iterator_category< Facade1 >::type, random_access_traversal_tag >
98 , is_traversal_at_least< typename iterator_category< Facade2 >::type, random_access_traversal_tag >
105 // Generates associated types for an iterator_facade with the
110 , class CategoryOrTraversal
114 struct iterator_facade_types
116 typedef typename facade_iterator_category<
117 CategoryOrTraversal, ValueParam, Reference
118 >::type iterator_category;
120 typedef typename remove_const<ValueParam>::type value_type;
122 // Not the real associated pointer type
123 typedef typename mpl::eval_if<
124 boost::iterators::detail::iterator_writability_disabled<ValueParam,Reference>
125 , add_pointer<const value_type>
126 , add_pointer<value_type>
129 # if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) \
130 && (BOOST_WORKAROUND(_STLPORT_VERSION, BOOST_TESTED_AT(0x452)) \
131 || BOOST_WORKAROUND(BOOST_DINKUMWARE_STDLIB, BOOST_TESTED_AT(310))) \
132 || BOOST_WORKAROUND(BOOST_RWSTD_VER, BOOST_TESTED_AT(0x20101)) \
133 || BOOST_WORKAROUND(BOOST_DINKUMWARE_STDLIB, <= 310)
135 // To interoperate with some broken library/compiler
136 // combinations, user-defined iterators must be derived from
137 // std::iterator. It is possible to implement a standard
138 // library for broken compilers without this limitation.
139 # define BOOST_ITERATOR_FACADE_NEEDS_ITERATOR_BASE 1
142 iterator<iterator_category, value_type, Difference, pointer, Reference>
147 // iterators whose dereference operators reference the same value
148 // for all iterators into the same sequence (like many input
149 // iterators) need help with their postfix ++: the referenced
150 // value must be read and stored away before the increment occurs
151 // so that *a++ yields the originally referenced element and not
153 template <class Iterator>
154 class postfix_increment_proxy
156 typedef typename iterator_value<Iterator>::type value_type;
158 explicit postfix_increment_proxy(Iterator const& x)
162 // Returning a mutable reference allows nonsense like
163 // (*r++).mutate(), but it imposes fewer assumptions about the
164 // behavior of the value_type. In particular, recall that
165 // (*r).mutate() is legal if operator* returns by value.
169 return this->stored_value;
172 mutable value_type stored_value;
176 // In general, we can't determine that such an iterator isn't
177 // writable -- we also need to store a copy of the old iterator so
178 // that it can be written into.
179 template <class Iterator>
180 class writable_postfix_increment_proxy
182 typedef typename iterator_value<Iterator>::type value_type;
184 explicit writable_postfix_increment_proxy(Iterator const& x)
189 // Dereferencing must return a proxy so that both *r++ = o and
190 // value_type(*r++) can work. In this case, *r is the same as
191 // *r++, and the conversion operator below is used to ensure
193 writable_postfix_increment_proxy const&
199 // Provides readability of *r++
200 operator value_type&() const
205 // Provides writability of *r++
207 T const& operator=(T const& x) const
209 *this->stored_iterator = x;
213 // This overload just in case only non-const objects are writable
215 T& operator=(T& x) const
217 *this->stored_iterator = x;
222 operator Iterator const&() const
224 return stored_iterator;
228 mutable value_type stored_value;
229 Iterator stored_iterator;
232 # ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
234 template <class Reference, class Value>
235 struct is_non_proxy_reference_impl
240 static typename mpl::if_<
243 , Value const volatile*
247 >::type& helper(R const&);
249 BOOST_STATIC_CONSTANT(bool, value = sizeof(helper(r)) == 1);
252 template <class Reference, class Value>
253 struct is_non_proxy_reference
255 is_non_proxy_reference_impl<Reference, Value>::value
259 template <class Reference, class Value>
260 struct is_non_proxy_reference
262 typename remove_reference<Reference>::type
264 , Value const volatile*
269 // A metafunction to choose the result type of postfix ++
271 // Because the C++98 input iterator requirements say that *r++ has
272 // type T (value_type), implementations of some standard
273 // algorithms like lexicographical_compare may use constructions
278 // If *r++ returns a proxy (as required if r is writable but not
279 // multipass), this sort of expression will fail unless the proxy
280 // supports the operator<. Since there are any number of such
281 // operations, we're not going to try to support them. Therefore,
282 // even if r++ returns a proxy, *r++ will only return a proxy if
283 // *r also returns a proxy.
284 template <class Iterator, class Value, class Reference, class CategoryOrTraversal>
285 struct postfix_increment_result
288 // A proxy is only needed for readable iterators
291 // Use add_lvalue_reference to form `reference to Value` due to
292 // some (strict) C++03 compilers (e.g. `gcc -std=c++03`) reject
293 // 'reference-to-reference' in the template which described in CWG
295 // http://www.open-std.org/Jtc1/sc22/wg21/docs/cwg_defects.html#106
296 , typename add_lvalue_reference<Value const>::type
299 // No multipass iterator can have values that disappear
300 // before positions can be re-visited
303 typename iterator_category_to_traversal<CategoryOrTraversal>::type
304 , forward_traversal_tag
309 is_non_proxy_reference<Reference,Value>
310 , postfix_increment_proxy<Iterator>
311 , writable_postfix_increment_proxy<Iterator>
313 , mpl::identity<Iterator>
317 // operator->() needs special support for input iterators to strictly meet the
318 // standard's requirements. If *i is not a reference type, we must still
319 // produce an lvalue to which a pointer can be formed. We do that by
320 // returning a proxy object containing an instance of the reference object.
321 template <class Reference, class Pointer>
322 struct operator_arrow_dispatch // proxy references
326 explicit proxy(Reference const & x) : m_ref(x) {}
327 Reference* operator->() { return boost::addressof(m_ref); }
328 // This function is needed for MWCW and BCC, which won't call
329 // operator-> again automatically per 13.3.1.2 para 8
330 operator Reference*() { return boost::addressof(m_ref); }
333 typedef proxy result_type;
334 static result_type apply(Reference const & x)
336 return result_type(x);
340 template <class T, class Pointer>
341 struct operator_arrow_dispatch<T&, Pointer> // "real" references
343 typedef Pointer result_type;
344 static result_type apply(T& x)
346 return boost::addressof(x);
350 // A proxy return type for operator[], needed to deal with
351 // iterators that may invalidate referents upon destruction.
352 // Consider the temporary iterator in *(a + n)
353 template <class Iterator>
354 class operator_brackets_proxy
356 // Iterator is actually an iterator_facade, so we do not have to
357 // go through iterator_traits to access the traits.
358 typedef typename Iterator::reference reference;
359 typedef typename Iterator::value_type value_type;
362 operator_brackets_proxy(Iterator const& iter)
366 operator reference() const
371 operator_brackets_proxy& operator=(value_type const& val)
381 // A metafunction that determines whether operator[] must return a
382 // proxy, or whether it can simply return a copy of the value_type.
383 template <class ValueType, class Reference>
384 struct use_operator_brackets_proxy
387 // Really we want an is_copy_constructible trait here,
388 // but is_POD will have to suffice in the meantime.
389 boost::is_POD<ValueType>
390 , iterator_writability_disabled<ValueType,Reference>
395 template <class Iterator, class Value, class Reference>
396 struct operator_brackets_result
398 typedef typename mpl::if_<
399 use_operator_brackets_proxy<Value,Reference>
400 , operator_brackets_proxy<Iterator>
405 template <class Iterator>
406 operator_brackets_proxy<Iterator> make_operator_brackets_result(Iterator const& iter, mpl::true_)
408 return operator_brackets_proxy<Iterator>(iter);
411 template <class Iterator>
412 typename Iterator::value_type make_operator_brackets_result(Iterator const& iter, mpl::false_)
417 struct choose_difference_type
419 template <class I1, class I2>
422 # ifdef BOOST_NO_ONE_WAY_ITERATOR_INTEROP
423 iterator_difference<I1>
426 is_convertible<I2,I1>
427 , iterator_difference<I1>
428 , iterator_difference<I2>
438 , class CategoryOrTraversal
441 , bool IsBidirectionalTraversal
442 , bool IsRandomAccessTraversal
444 class iterator_facade_base;
446 } // namespace detail
449 // Macros which describe the declarations of binary operators
450 # ifdef BOOST_NO_STRICT_ITERATOR_INTEROPERABILITY
451 # define BOOST_ITERATOR_FACADE_INTEROP_HEAD_IMPL(prefix, op, result_type, enabler) \
453 class Derived1, class V1, class TC1, class Reference1, class Difference1 \
454 , class Derived2, class V2, class TC2, class Reference2, class Difference2 \
456 prefix typename mpl::apply2<result_type,Derived1,Derived2>::type \
458 iterator_facade<Derived1, V1, TC1, Reference1, Difference1> const& lhs \
459 , iterator_facade<Derived2, V2, TC2, Reference2, Difference2> const& rhs)
461 # define BOOST_ITERATOR_FACADE_INTEROP_HEAD_IMPL(prefix, op, result_type, enabler) \
463 class Derived1, class V1, class TC1, class Reference1, class Difference1 \
464 , class Derived2, class V2, class TC2, class Reference2, class Difference2 \
466 prefix typename enabler< \
468 , typename mpl::apply2<result_type,Derived1,Derived2>::type \
471 iterator_facade<Derived1, V1, TC1, Reference1, Difference1> const& lhs \
472 , iterator_facade<Derived2, V2, TC2, Reference2, Difference2> const& rhs)
475 # define BOOST_ITERATOR_FACADE_INTEROP_HEAD(prefix, op, result_type) \
476 BOOST_ITERATOR_FACADE_INTEROP_HEAD_IMPL(prefix, op, result_type, boost::iterators::detail::enable_if_interoperable)
478 # define BOOST_ITERATOR_FACADE_INTEROP_RANDOM_ACCESS_HEAD(prefix, op, result_type) \
479 BOOST_ITERATOR_FACADE_INTEROP_HEAD_IMPL(prefix, op, result_type, boost::iterators::detail::enable_if_interoperable_and_random_access_traversal)
481 # define BOOST_ITERATOR_FACADE_PLUS_HEAD(prefix,args) \
482 template <class Derived, class V, class TC, class R, class D> \
483 prefix typename boost::iterators::enable_if< \
484 boost::iterators::detail::is_traversal_at_least< TC, boost::iterators::random_access_traversal_tag >, \
486 >::type operator+ args
489 // Helper class for granting access to the iterator core interface.
491 // The simple core interface is used by iterator_facade. The core
492 // interface of a user/library defined iterator type should not be made public
493 // so that it does not clutter the public interface. Instead iterator_core_access
494 // should be made friend so that iterator_facade can access the core
495 // interface through iterator_core_access.
497 class iterator_core_access
499 # if defined(BOOST_NO_MEMBER_TEMPLATE_FRIENDS)
500 // Tasteless as this may seem, making all members public allows member templates
501 // to work in the absence of member template friends.
505 template <class I, class V, class TC, class R, class D> friend class iterator_facade;
506 template <class I, class V, class TC, class R, class D, bool IsBidirectionalTraversal, bool IsRandomAccessTraversal>
507 friend class detail::iterator_facade_base;
509 # define BOOST_ITERATOR_FACADE_RELATION(op) \
510 BOOST_ITERATOR_FACADE_INTEROP_HEAD(friend,op, boost::iterators::detail::always_bool2);
512 BOOST_ITERATOR_FACADE_RELATION(==)
513 BOOST_ITERATOR_FACADE_RELATION(!=)
515 # undef BOOST_ITERATOR_FACADE_RELATION
517 # define BOOST_ITERATOR_FACADE_RANDOM_ACCESS_RELATION(op) \
518 BOOST_ITERATOR_FACADE_INTEROP_RANDOM_ACCESS_HEAD(friend,op, boost::iterators::detail::always_bool2);
520 BOOST_ITERATOR_FACADE_RANDOM_ACCESS_RELATION(<)
521 BOOST_ITERATOR_FACADE_RANDOM_ACCESS_RELATION(>)
522 BOOST_ITERATOR_FACADE_RANDOM_ACCESS_RELATION(<=)
523 BOOST_ITERATOR_FACADE_RANDOM_ACCESS_RELATION(>=)
525 # undef BOOST_ITERATOR_FACADE_RANDOM_ACCESS_RELATION
527 BOOST_ITERATOR_FACADE_INTEROP_RANDOM_ACCESS_HEAD(
528 friend, -, boost::iterators::detail::choose_difference_type)
531 BOOST_ITERATOR_FACADE_PLUS_HEAD(
533 , (iterator_facade<Derived, V, TC, R, D> const&
534 , typename Derived::difference_type)
538 BOOST_ITERATOR_FACADE_PLUS_HEAD(
540 , (typename Derived::difference_type
541 , iterator_facade<Derived, V, TC, R, D> const&)
547 template <class Facade>
548 static typename Facade::reference dereference(Facade const& f)
550 return f.dereference();
553 template <class Facade>
554 static void increment(Facade& f)
559 template <class Facade>
560 static void decrement(Facade& f)
565 template <class Facade1, class Facade2>
566 static bool equal(Facade1 const& f1, Facade2 const& f2, mpl::true_)
571 template <class Facade1, class Facade2>
572 static bool equal(Facade1 const& f1, Facade2 const& f2, mpl::false_)
577 template <class Facade>
578 static void advance(Facade& f, typename Facade::difference_type n)
583 template <class Facade1, class Facade2>
584 static typename Facade1::difference_type distance_from(
585 Facade1 const& f1, Facade2 const& f2, mpl::true_)
587 return -f1.distance_to(f2);
590 template <class Facade1, class Facade2>
591 static typename Facade2::difference_type distance_from(
592 Facade1 const& f1, Facade2 const& f2, mpl::false_)
594 return f2.distance_to(f1);
598 // Curiously Recurring Template interface.
600 template <class I, class V, class TC, class R, class D>
601 static I& derived(iterator_facade<I,V,TC,R,D>& facade)
603 return *static_cast<I*>(&facade);
606 template <class I, class V, class TC, class R, class D>
607 static I const& derived(iterator_facade<I,V,TC,R,D> const& facade)
609 return *static_cast<I const*>(&facade);
612 // objects of this class are useless
613 BOOST_DELETED_FUNCTION(iterator_core_access())
618 // Implementation for forward traversal iterators
622 , class CategoryOrTraversal
626 class iterator_facade_base< Derived, Value, CategoryOrTraversal, Reference, Difference, false, false >
627 # ifdef BOOST_ITERATOR_FACADE_NEEDS_ITERATOR_BASE
628 : public boost::iterators::detail::iterator_facade_types<
629 Value, CategoryOrTraversal, Reference, Difference
631 # undef BOOST_ITERATOR_FACADE_NEEDS_ITERATOR_BASE
635 typedef boost::iterators::detail::iterator_facade_types<
636 Value, CategoryOrTraversal, Reference, Difference
639 typedef boost::iterators::detail::operator_arrow_dispatch<
641 , typename associated_types::pointer
642 > operator_arrow_dispatch_;
645 typedef typename associated_types::value_type value_type;
646 typedef Reference reference;
647 typedef Difference difference_type;
649 typedef typename operator_arrow_dispatch_::result_type pointer;
651 typedef typename associated_types::iterator_category iterator_category;
654 reference operator*() const
656 return iterator_core_access::dereference(this->derived());
659 pointer operator->() const
661 return operator_arrow_dispatch_::apply(*this->derived());
664 Derived& operator++()
666 iterator_core_access::increment(this->derived());
667 return this->derived();
672 // Curiously Recurring Template interface.
676 return *static_cast<Derived*>(this);
679 Derived const& derived() const
681 return *static_cast<Derived const*>(this);
685 // Implementation for bidirectional traversal iterators
689 , class CategoryOrTraversal
693 class iterator_facade_base< Derived, Value, CategoryOrTraversal, Reference, Difference, true, false > :
694 public iterator_facade_base< Derived, Value, CategoryOrTraversal, Reference, Difference, false, false >
697 Derived& operator--()
699 iterator_core_access::decrement(this->derived());
700 return this->derived();
703 Derived operator--(int)
705 Derived tmp(this->derived());
711 // Implementation for random access traversal iterators
715 , class CategoryOrTraversal
719 class iterator_facade_base< Derived, Value, CategoryOrTraversal, Reference, Difference, true, true > :
720 public iterator_facade_base< Derived, Value, CategoryOrTraversal, Reference, Difference, true, false >
723 typedef iterator_facade_base< Derived, Value, CategoryOrTraversal, Reference, Difference, true, false > base_type;
726 typedef typename base_type::reference reference;
727 typedef typename base_type::difference_type difference_type;
730 typename boost::iterators::detail::operator_brackets_result<Derived, Value, reference>::type
731 operator[](difference_type n) const
733 typedef boost::iterators::detail::use_operator_brackets_proxy<Value, Reference> use_proxy;
735 return boost::iterators::detail::make_operator_brackets_result<Derived>(
741 Derived& operator+=(difference_type n)
743 iterator_core_access::advance(this->derived(), n);
744 return this->derived();
747 Derived& operator-=(difference_type n)
749 iterator_core_access::advance(this->derived(), -n);
750 return this->derived();
753 Derived operator-(difference_type x) const
755 Derived result(this->derived());
760 } // namespace detail
763 // iterator_facade - use as a public base class for defining new
764 // standard-conforming iterators.
767 class Derived // The derived iterator type being constructed
769 , class CategoryOrTraversal
770 , class Reference = Value&
771 , class Difference = std::ptrdiff_t
773 class iterator_facade :
774 public detail::iterator_facade_base<
780 detail::is_traversal_at_least< CategoryOrTraversal, bidirectional_traversal_tag >::value,
781 detail::is_traversal_at_least< CategoryOrTraversal, random_access_traversal_tag >::value
785 // For use by derived classes
786 typedef iterator_facade<Derived,Value,CategoryOrTraversal,Reference,Difference> iterator_facade_;
789 template <class I, class V, class TC, class R, class D>
790 inline typename boost::iterators::detail::postfix_increment_result<I,V,R,TC>::type
792 iterator_facade<I,V,TC,R,D>& i
796 typename boost::iterators::detail::postfix_increment_result<I,V,R,TC>::type
797 tmp(*static_cast<I*>(&i));
806 // Comparison operator implementation. The library supplied operators
807 // enables the user to provide fully interoperable constant/mutable
808 // iterator types. I.e. the library provides all operators
809 // for all mutable/constant iterator combinations.
811 // Note though that this kind of interoperability for constant/mutable
812 // iterators is not required by the standard for container iterators.
813 // All the standard asks for is a conversion mutable -> constant.
814 // Most standard library implementations nowadays provide fully interoperable
815 // iterator implementations, but there are still heavily used implementations
816 // that do not provide them. (Actually it's even worse, they do not provide
817 // them for only a few iterators.)
819 // ?? Maybe a BOOST_ITERATOR_NO_FULL_INTEROPERABILITY macro should
820 // enable the user to turn off mixed type operators
822 // The library takes care to provide only the right operator overloads.
825 // bool operator==(Iterator, Iterator);
826 // bool operator==(ConstIterator, Iterator);
827 // bool operator==(Iterator, ConstIterator);
828 // bool operator==(ConstIterator, ConstIterator);
832 // In order to do so it uses c++ idioms that are not yet widely supported
833 // by current compiler releases. The library is designed to degrade gracefully
834 // in the face of compiler deficiencies. In general compiler
835 // deficiencies result in less strict error checking and more obscure
836 // error messages, functionality is not affected.
838 // For full operation compiler support for "Substitution Failure Is Not An Error"
839 // (aka. enable_if) and boost::is_convertible is required.
841 // The following problems occur if support is lacking.
846 // AdaptorA<Iterator1> a1;
847 // AdaptorA<Iterator2> a2;
849 // // This will result in a no such overload error in full operation
850 // // If enable_if or is_convertible is not supported
851 // // The instantiation will fail with an error hopefully indicating that
852 // // there is no operator== for Iterator1, Iterator2
853 // // The same will happen if no enable_if is used to remove
854 // // false overloads from the templated conversion constructor
860 // AdaptorA<Iterator> a;
861 // AdaptorB<Iterator> b;
863 // // This will result in a no such overload error in full operation
864 // // If enable_if is not supported the static assert used
865 // // in the operator implementation will fail.
866 // // This will accidently work if is_convertible is not supported.
872 # ifdef BOOST_NO_ONE_WAY_ITERATOR_INTEROP
873 # define BOOST_ITERATOR_CONVERTIBLE(a,b) mpl::true_()
875 # define BOOST_ITERATOR_CONVERTIBLE(a,b) is_convertible<a,b>()
878 # define BOOST_ITERATOR_FACADE_INTEROP(op, result_type, return_prefix, base_op) \
879 BOOST_ITERATOR_FACADE_INTEROP_HEAD(inline, op, result_type) \
881 /* For those compilers that do not support enable_if */ \
882 BOOST_STATIC_ASSERT(( \
883 is_interoperable< Derived1, Derived2 >::value \
885 return_prefix iterator_core_access::base_op( \
886 *static_cast<Derived1 const*>(&lhs) \
887 , *static_cast<Derived2 const*>(&rhs) \
888 , BOOST_ITERATOR_CONVERTIBLE(Derived2,Derived1) \
892 # define BOOST_ITERATOR_FACADE_RELATION(op, return_prefix, base_op) \
893 BOOST_ITERATOR_FACADE_INTEROP( \
895 , boost::iterators::detail::always_bool2 \
900 BOOST_ITERATOR_FACADE_RELATION(==, return, equal)
901 BOOST_ITERATOR_FACADE_RELATION(!=, return !, equal)
903 # undef BOOST_ITERATOR_FACADE_RELATION
906 # define BOOST_ITERATOR_FACADE_INTEROP_RANDOM_ACCESS(op, result_type, return_prefix, base_op) \
907 BOOST_ITERATOR_FACADE_INTEROP_RANDOM_ACCESS_HEAD(inline, op, result_type) \
909 /* For those compilers that do not support enable_if */ \
910 BOOST_STATIC_ASSERT(( \
911 is_interoperable< Derived1, Derived2 >::value && \
912 boost::iterators::detail::is_traversal_at_least< typename iterator_category< Derived1 >::type, random_access_traversal_tag >::value && \
913 boost::iterators::detail::is_traversal_at_least< typename iterator_category< Derived2 >::type, random_access_traversal_tag >::value \
915 return_prefix iterator_core_access::base_op( \
916 *static_cast<Derived1 const*>(&lhs) \
917 , *static_cast<Derived2 const*>(&rhs) \
918 , BOOST_ITERATOR_CONVERTIBLE(Derived2,Derived1) \
922 # define BOOST_ITERATOR_FACADE_RANDOM_ACCESS_RELATION(op, return_prefix, base_op) \
923 BOOST_ITERATOR_FACADE_INTEROP_RANDOM_ACCESS( \
925 , boost::iterators::detail::always_bool2 \
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)
933 BOOST_ITERATOR_FACADE_RANDOM_ACCESS_RELATION(>=, return 0 <=, distance_from)
935 # undef BOOST_ITERATOR_FACADE_RANDOM_ACCESS_RELATION
937 // operator- requires an additional part in the static assertion
938 BOOST_ITERATOR_FACADE_INTEROP_RANDOM_ACCESS(
940 , boost::iterators::detail::choose_difference_type
945 # undef BOOST_ITERATOR_FACADE_INTEROP
946 # undef BOOST_ITERATOR_FACADE_INTEROP_RANDOM_ACCESS
948 # define BOOST_ITERATOR_FACADE_PLUS(args) \
949 BOOST_ITERATOR_FACADE_PLUS_HEAD(inline, args) \
951 Derived tmp(static_cast<Derived const&>(i)); \
955 BOOST_ITERATOR_FACADE_PLUS((
956 iterator_facade<Derived, V, TC, R, D> const& i
957 , typename Derived::difference_type n
960 BOOST_ITERATOR_FACADE_PLUS((
961 typename Derived::difference_type n
962 , iterator_facade<Derived, V, TC, R, D> const& i
965 # undef BOOST_ITERATOR_FACADE_PLUS
966 # undef BOOST_ITERATOR_FACADE_PLUS_HEAD
968 # undef BOOST_ITERATOR_FACADE_INTEROP_HEAD
969 # undef BOOST_ITERATOR_FACADE_INTEROP_RANDOM_ACCESS_HEAD
970 # undef BOOST_ITERATOR_FACADE_INTEROP_HEAD_IMPL
972 } // namespace iterators
974 using iterators::iterator_core_access;
975 using iterators::iterator_facade;
979 #include <boost/iterator/detail/config_undef.hpp>
981 #endif // BOOST_ITERATOR_FACADE_23022003THW_HPP