X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=boost%2Fboost%2Fiterator%2Fiterator_archetypes.hpp;h=039de1cf7409570a55a02c6c400ce27eb19eba60;hb=c48091f33a773732fa6c789927e5833e44108d9d;hp=74b250b10b1dd90324ca8051ee86c59d8203dbc1;hpb=1fc4cdd807cbdba7d43ff903e9c75b421f4a4644;p=lyx.git diff --git a/boost/boost/iterator/iterator_archetypes.hpp b/boost/boost/iterator/iterator_archetypes.hpp index 74b250b10b..039de1cf74 100644 --- a/boost/boost/iterator/iterator_archetypes.hpp +++ b/boost/boost/iterator/iterator_archetypes.hpp @@ -1,515 +1,515 @@ -// (C) Copyright Jeremy Siek 2002. -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_ITERATOR_ARCHETYPES_HPP -#define BOOST_ITERATOR_ARCHETYPES_HPP - -#include -#include -#include -#include - -#include - -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -namespace boost { - -template -struct access_archetype; - -template -struct traversal_archetype; - -namespace iterator_archetypes -{ - enum { - readable_iterator_bit = 1 - , writable_iterator_bit = 2 - , swappable_iterator_bit = 4 - , lvalue_iterator_bit = 8 - }; - - // Not quite tags, since dispatching wouldn't work. - typedef mpl::int_::type readable_iterator_t; - typedef mpl::int_::type writable_iterator_t; - - typedef mpl::int_< - (readable_iterator_bit|writable_iterator_bit) - >::type readable_writable_iterator_t; - - typedef mpl::int_< - (readable_iterator_bit|lvalue_iterator_bit) - >::type readable_lvalue_iterator_t; - - typedef mpl::int_< - (lvalue_iterator_bit|writable_iterator_bit) - >::type writable_lvalue_iterator_t; - - typedef mpl::int_::type swappable_iterator_t; - typedef mpl::int_::type lvalue_iterator_t; - - template - struct has_access - : mpl::equal_to< - mpl::bitand_ - , Base - > - {}; -} - -namespace detail -{ - template - struct assign_proxy - { - assign_proxy& operator=(T) { return *this; } - }; - - template - struct read_proxy - { - operator T() { return static_object::get(); } - }; - - template - struct read_write_proxy - : read_proxy // Use to inherit from assign_proxy, but that doesn't work. -JGS - { - read_write_proxy& operator=(T) { return *this; } - }; - - template - struct arrow_proxy - { - T const* operator->() const { return 0; } - }; - - struct no_operator_brackets {}; - - template - struct readable_operator_brackets - { - read_proxy operator[](std::ptrdiff_t n) const { return read_proxy(); } - }; - - template - struct writable_operator_brackets - { - read_write_proxy operator[](std::ptrdiff_t n) const { return read_write_proxy(); } - }; - - template - struct operator_brackets - : mpl::aux::msvc_eti_base< - typename mpl::eval_if< - is_convertible - , mpl::eval_if< - iterator_archetypes::has_access< - AccessCategory - , iterator_archetypes::writable_iterator_t - > - , mpl::identity > - , mpl::if_< - iterator_archetypes::has_access< - AccessCategory - , iterator_archetypes::readable_iterator_t - > - , readable_operator_brackets - , no_operator_brackets - > - > - , mpl::identity - >::type - >::type - {}; - - template - struct traversal_archetype_impl - { - template struct archetype; - }; - - // Constructor argument for those iterators that - // are not default constructible - struct ctor_arg {}; - - template - struct traversal_archetype_ - : mpl::aux::msvc_eti_base< - typename traversal_archetype_impl::template archetype - >::type - { - typedef typename - traversal_archetype_impl::template archetype - base; - - traversal_archetype_() {} - - traversal_archetype_(ctor_arg arg) - : base(arg) - {} - }; - - template <> - struct traversal_archetype_impl - { - template - struct archetype - { - explicit archetype(ctor_arg) {} - - struct bogus { }; // This use to be void, but that causes trouble for iterator_facade. Need more research. -JGS - typedef bogus difference_type; - - Derived& operator++() { return (Derived&)static_object::get(); } - Derived operator++(int) const { return (Derived&)static_object::get(); } - }; - }; - - template <> - struct traversal_archetype_impl - { - template - struct archetype - : public equality_comparable< traversal_archetype_ >, - public traversal_archetype_ - { - explicit archetype(ctor_arg arg) - : traversal_archetype_(arg) - {} - - typedef std::ptrdiff_t difference_type; - }; - }; - - template - bool operator==(traversal_archetype_ const&, - traversal_archetype_ const&) { return true; } - -#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300) - // doesn't seem to pick up != from equality_comparable - template - bool operator!=(traversal_archetype_ const&, - traversal_archetype_ const&) { return true; } -#endif - template <> - struct traversal_archetype_impl - { - template - struct archetype - : public traversal_archetype_ - { - archetype() - : traversal_archetype_(ctor_arg()) - {} - }; - }; - - template <> - struct traversal_archetype_impl - { - template - struct archetype - : public traversal_archetype_ - { - Derived& operator--() { return static_object::get(); } - Derived operator--(int) const { return static_object::get(); } - }; - }; - - template <> - struct traversal_archetype_impl - { - template - struct archetype - : public traversal_archetype_ - { - Derived& operator+=(std::ptrdiff_t) { return static_object::get(); } - Derived& operator-=(std::ptrdiff_t) { return static_object::get(); } - }; - }; - - template - Derived& operator+(traversal_archetype_ const&, - std::ptrdiff_t) { return static_object::get(); } - - template - Derived& operator+(std::ptrdiff_t, - traversal_archetype_ const&) - { return static_object::get(); } - - template - Derived& operator-(traversal_archetype_ const&, - std::ptrdiff_t) - { return static_object::get(); } - - template - std::ptrdiff_t operator-(traversal_archetype_ const&, - traversal_archetype_ const&) - { return 0; } - - template - bool operator<(traversal_archetype_ const&, - traversal_archetype_ const&) - { return true; } - - template - bool operator>(traversal_archetype_ const&, - traversal_archetype_ const&) - { return true; } - - template - bool operator<=(traversal_archetype_ const&, - traversal_archetype_ const&) - { return true; } - - template - bool operator>=(traversal_archetype_ const&, - traversal_archetype_ const&) - { return true; } - - struct bogus_type; - - template - struct convertible_type - : mpl::if_< is_const, - typename remove_const::type, - bogus_type > - {}; - -} // namespace detail - - -template struct undefined; - -template -struct iterator_access_archetype_impl -{ - template struct archetype; -}; - -template -struct iterator_access_archetype - : mpl::aux::msvc_eti_base< - typename iterator_access_archetype_impl< - AccessCategory - >::template archetype - >::type -{ -}; - -template <> -struct iterator_access_archetype_impl< - iterator_archetypes::readable_iterator_t -> -{ - template - struct archetype - { - typedef typename remove_cv::type value_type; - typedef Value reference; - typedef Value* pointer; - - value_type operator*() const { return static_object::get(); } - - detail::arrow_proxy operator->() const { return detail::arrow_proxy(); } - }; -}; - -template <> -struct iterator_access_archetype_impl< - iterator_archetypes::writable_iterator_t -> -{ - template - struct archetype - { -# if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) - BOOST_STATIC_ASSERT(!is_const::value); -# endif - typedef void value_type; - typedef void reference; - typedef void pointer; - - detail::assign_proxy operator*() const { return detail::assign_proxy(); } - }; -}; - -template <> -struct iterator_access_archetype_impl< - iterator_archetypes::readable_writable_iterator_t -> -{ - template - struct archetype - : public virtual iterator_access_archetype< - Value, iterator_archetypes::readable_iterator_t - > - { - typedef detail::read_write_proxy reference; - - detail::read_write_proxy operator*() const { return detail::read_write_proxy(); } - }; -}; - -template <> -struct iterator_access_archetype_impl -{ - template - struct archetype - : public virtual iterator_access_archetype< - Value, iterator_archetypes::readable_iterator_t - > - { - typedef Value& reference; - - Value& operator*() const { return static_object::get(); } - Value* operator->() const { return 0; } - }; -}; - -template <> -struct iterator_access_archetype_impl -{ - template - struct archetype - : public virtual iterator_access_archetype< - Value, iterator_archetypes::readable_lvalue_iterator_t - > - { -# if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) - BOOST_STATIC_ASSERT((!is_const::value)); -# endif - }; -}; - - -template -struct iterator_archetype; - -template -struct traversal_archetype_base - : detail::operator_brackets< - typename remove_cv::type - , AccessCategory - , TraversalCategory - > - , detail::traversal_archetype_< - iterator_archetype - , Value - , TraversalCategory - > -{ -}; - -namespace detail -{ - template - struct iterator_archetype_base - : iterator_access_archetype - , traversal_archetype_base - { - typedef iterator_access_archetype access; - - typedef typename detail::facade_iterator_category< - TraversalCategory - , typename mpl::eval_if< - iterator_archetypes::has_access< - AccessCategory, iterator_archetypes::writable_iterator_t - > - , remove_const - , add_const - >::type - , typename access::reference - >::type iterator_category; - - // Needed for some broken libraries (see below) - typedef boost::iterator< - iterator_category - , Value - , typename traversal_archetype_base< - Value, AccessCategory, TraversalCategory - >::difference_type - , typename access::pointer - , typename access::reference - > workaround_iterator_base; - }; -} - -template -struct iterator_archetype - : public detail::iterator_archetype_base - - // These broken libraries require derivation from std::iterator - // (or related magic) in order to handle iter_swap and other - // iterator operations -# if BOOST_WORKAROUND(BOOST_DINKUMWARE_STDLIB, < 310) \ - || BOOST_WORKAROUND(_RWSTD_VER, BOOST_TESTED_AT(0x20101)) - , public detail::iterator_archetype_base< - Value, AccessCategory, TraversalCategory - >::workaround_iterator_base -# endif -{ - // Derivation from std::iterator above caused references to nested - // types to be ambiguous, so now we have to redeclare them all - // here. -# if BOOST_WORKAROUND(BOOST_DINKUMWARE_STDLIB, < 310) \ - || BOOST_WORKAROUND(_RWSTD_VER, BOOST_TESTED_AT(0x20101)) - - typedef detail::iterator_archetype_base< - Value,AccessCategory,TraversalCategory - > base; - - typedef typename base::value_type value_type; - typedef typename base::reference reference; - typedef typename base::pointer pointer; - typedef typename base::difference_type difference_type; - typedef typename base::iterator_category iterator_category; -# endif - - iterator_archetype() { } - iterator_archetype(iterator_archetype const& x) - : detail::iterator_archetype_base< - Value - , AccessCategory - , TraversalCategory - >(x) - {} - - iterator_archetype& operator=(iterator_archetype const&) - { return *this; } - -# if 0 - // Optional conversion from mutable - iterator_archetype( - iterator_archetype< - typename detail::convertible_type::type - , AccessCategory - , TraversalCategory> const& - ); -# endif -}; - -} // namespace boost - - -#endif // BOOST_ITERATOR_ARCHETYPES_HPP +// (C) Copyright Jeremy Siek 2002. +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_ITERATOR_ARCHETYPES_HPP +#define BOOST_ITERATOR_ARCHETYPES_HPP + +#include +#include +#include +#include + +#include + +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +namespace boost { + +template +struct access_archetype; + +template +struct traversal_archetype; + +namespace iterator_archetypes +{ + enum { + readable_iterator_bit = 1 + , writable_iterator_bit = 2 + , swappable_iterator_bit = 4 + , lvalue_iterator_bit = 8 + }; + + // Not quite tags, since dispatching wouldn't work. + typedef mpl::int_::type readable_iterator_t; + typedef mpl::int_::type writable_iterator_t; + + typedef mpl::int_< + (readable_iterator_bit|writable_iterator_bit) + >::type readable_writable_iterator_t; + + typedef mpl::int_< + (readable_iterator_bit|lvalue_iterator_bit) + >::type readable_lvalue_iterator_t; + + typedef mpl::int_< + (lvalue_iterator_bit|writable_iterator_bit) + >::type writable_lvalue_iterator_t; + + typedef mpl::int_::type swappable_iterator_t; + typedef mpl::int_::type lvalue_iterator_t; + + template + struct has_access + : mpl::equal_to< + mpl::bitand_ + , Base + > + {}; +} + +namespace detail +{ + template + struct assign_proxy + { + assign_proxy& operator=(T) { return *this; } + }; + + template + struct read_proxy + { + operator T() { return static_object::get(); } + }; + + template + struct read_write_proxy + : read_proxy // Use to inherit from assign_proxy, but that doesn't work. -JGS + { + read_write_proxy& operator=(T) { return *this; } + }; + + template + struct arrow_proxy + { + T const* operator->() const { return 0; } + }; + + struct no_operator_brackets {}; + + template + struct readable_operator_brackets + { + read_proxy operator[](std::ptrdiff_t n) const { return read_proxy(); } + }; + + template + struct writable_operator_brackets + { + read_write_proxy operator[](std::ptrdiff_t n) const { return read_write_proxy(); } + }; + + template + struct operator_brackets + : mpl::aux::msvc_eti_base< + typename mpl::eval_if< + is_convertible + , mpl::eval_if< + iterator_archetypes::has_access< + AccessCategory + , iterator_archetypes::writable_iterator_t + > + , mpl::identity > + , mpl::if_< + iterator_archetypes::has_access< + AccessCategory + , iterator_archetypes::readable_iterator_t + > + , readable_operator_brackets + , no_operator_brackets + > + > + , mpl::identity + >::type + >::type + {}; + + template + struct traversal_archetype_impl + { + template struct archetype; + }; + + // Constructor argument for those iterators that + // are not default constructible + struct ctor_arg {}; + + template + struct traversal_archetype_ + : mpl::aux::msvc_eti_base< + typename traversal_archetype_impl::template archetype + >::type + { + typedef typename + traversal_archetype_impl::template archetype + base; + + traversal_archetype_() {} + + traversal_archetype_(ctor_arg arg) + : base(arg) + {} + }; + + template <> + struct traversal_archetype_impl + { + template + struct archetype + { + explicit archetype(ctor_arg) {} + + struct bogus { }; // This use to be void, but that causes trouble for iterator_facade. Need more research. -JGS + typedef bogus difference_type; + + Derived& operator++() { return (Derived&)static_object::get(); } + Derived operator++(int) const { return (Derived&)static_object::get(); } + }; + }; + + template <> + struct traversal_archetype_impl + { + template + struct archetype + : public equality_comparable< traversal_archetype_ >, + public traversal_archetype_ + { + explicit archetype(ctor_arg arg) + : traversal_archetype_(arg) + {} + + typedef std::ptrdiff_t difference_type; + }; + }; + + template + bool operator==(traversal_archetype_ const&, + traversal_archetype_ const&) { return true; } + +#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300) + // doesn't seem to pick up != from equality_comparable + template + bool operator!=(traversal_archetype_ const&, + traversal_archetype_ const&) { return true; } +#endif + template <> + struct traversal_archetype_impl + { + template + struct archetype + : public traversal_archetype_ + { + archetype() + : traversal_archetype_(ctor_arg()) + {} + }; + }; + + template <> + struct traversal_archetype_impl + { + template + struct archetype + : public traversal_archetype_ + { + Derived& operator--() { return static_object::get(); } + Derived operator--(int) const { return static_object::get(); } + }; + }; + + template <> + struct traversal_archetype_impl + { + template + struct archetype + : public traversal_archetype_ + { + Derived& operator+=(std::ptrdiff_t) { return static_object::get(); } + Derived& operator-=(std::ptrdiff_t) { return static_object::get(); } + }; + }; + + template + Derived& operator+(traversal_archetype_ const&, + std::ptrdiff_t) { return static_object::get(); } + + template + Derived& operator+(std::ptrdiff_t, + traversal_archetype_ const&) + { return static_object::get(); } + + template + Derived& operator-(traversal_archetype_ const&, + std::ptrdiff_t) + { return static_object::get(); } + + template + std::ptrdiff_t operator-(traversal_archetype_ const&, + traversal_archetype_ const&) + { return 0; } + + template + bool operator<(traversal_archetype_ const&, + traversal_archetype_ const&) + { return true; } + + template + bool operator>(traversal_archetype_ const&, + traversal_archetype_ const&) + { return true; } + + template + bool operator<=(traversal_archetype_ const&, + traversal_archetype_ const&) + { return true; } + + template + bool operator>=(traversal_archetype_ const&, + traversal_archetype_ const&) + { return true; } + + struct bogus_type; + + template + struct convertible_type + : mpl::if_< is_const, + typename remove_const::type, + bogus_type > + {}; + +} // namespace detail + + +template struct undefined; + +template +struct iterator_access_archetype_impl +{ + template struct archetype; +}; + +template +struct iterator_access_archetype + : mpl::aux::msvc_eti_base< + typename iterator_access_archetype_impl< + AccessCategory + >::template archetype + >::type +{ +}; + +template <> +struct iterator_access_archetype_impl< + iterator_archetypes::readable_iterator_t +> +{ + template + struct archetype + { + typedef typename remove_cv::type value_type; + typedef Value reference; + typedef Value* pointer; + + value_type operator*() const { return static_object::get(); } + + detail::arrow_proxy operator->() const { return detail::arrow_proxy(); } + }; +}; + +template <> +struct iterator_access_archetype_impl< + iterator_archetypes::writable_iterator_t +> +{ + template + struct archetype + { +# if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) + BOOST_STATIC_ASSERT(!is_const::value); +# endif + typedef void value_type; + typedef void reference; + typedef void pointer; + + detail::assign_proxy operator*() const { return detail::assign_proxy(); } + }; +}; + +template <> +struct iterator_access_archetype_impl< + iterator_archetypes::readable_writable_iterator_t +> +{ + template + struct archetype + : public virtual iterator_access_archetype< + Value, iterator_archetypes::readable_iterator_t + > + { + typedef detail::read_write_proxy reference; + + detail::read_write_proxy operator*() const { return detail::read_write_proxy(); } + }; +}; + +template <> +struct iterator_access_archetype_impl +{ + template + struct archetype + : public virtual iterator_access_archetype< + Value, iterator_archetypes::readable_iterator_t + > + { + typedef Value& reference; + + Value& operator*() const { return static_object::get(); } + Value* operator->() const { return 0; } + }; +}; + +template <> +struct iterator_access_archetype_impl +{ + template + struct archetype + : public virtual iterator_access_archetype< + Value, iterator_archetypes::readable_lvalue_iterator_t + > + { +# if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) + BOOST_STATIC_ASSERT((!is_const::value)); +# endif + }; +}; + + +template +struct iterator_archetype; + +template +struct traversal_archetype_base + : detail::operator_brackets< + typename remove_cv::type + , AccessCategory + , TraversalCategory + > + , detail::traversal_archetype_< + iterator_archetype + , Value + , TraversalCategory + > +{ +}; + +namespace detail +{ + template + struct iterator_archetype_base + : iterator_access_archetype + , traversal_archetype_base + { + typedef iterator_access_archetype access; + + typedef typename detail::facade_iterator_category< + TraversalCategory + , typename mpl::eval_if< + iterator_archetypes::has_access< + AccessCategory, iterator_archetypes::writable_iterator_t + > + , remove_const + , add_const + >::type + , typename access::reference + >::type iterator_category; + + // Needed for some broken libraries (see below) + typedef boost::iterator< + iterator_category + , Value + , typename traversal_archetype_base< + Value, AccessCategory, TraversalCategory + >::difference_type + , typename access::pointer + , typename access::reference + > workaround_iterator_base; + }; +} + +template +struct iterator_archetype + : public detail::iterator_archetype_base + + // These broken libraries require derivation from std::iterator + // (or related magic) in order to handle iter_swap and other + // iterator operations +# if BOOST_WORKAROUND(BOOST_DINKUMWARE_STDLIB, < 310) \ + || BOOST_WORKAROUND(_RWSTD_VER, BOOST_TESTED_AT(0x20101)) + , public detail::iterator_archetype_base< + Value, AccessCategory, TraversalCategory + >::workaround_iterator_base +# endif +{ + // Derivation from std::iterator above caused references to nested + // types to be ambiguous, so now we have to redeclare them all + // here. +# if BOOST_WORKAROUND(BOOST_DINKUMWARE_STDLIB, < 310) \ + || BOOST_WORKAROUND(_RWSTD_VER, BOOST_TESTED_AT(0x20101)) + + typedef detail::iterator_archetype_base< + Value,AccessCategory,TraversalCategory + > base; + + typedef typename base::value_type value_type; + typedef typename base::reference reference; + typedef typename base::pointer pointer; + typedef typename base::difference_type difference_type; + typedef typename base::iterator_category iterator_category; +# endif + + iterator_archetype() { } + iterator_archetype(iterator_archetype const& x) + : detail::iterator_archetype_base< + Value + , AccessCategory + , TraversalCategory + >(x) + {} + + iterator_archetype& operator=(iterator_archetype const&) + { return *this; } + +# if 0 + // Optional conversion from mutable + iterator_archetype( + iterator_archetype< + typename detail::convertible_type::type + , AccessCategory + , TraversalCategory> const& + ); +# endif +}; + +} // namespace boost + + +#endif // BOOST_ITERATOR_ARCHETYPES_HPP