diff --git a/include/boost/iterator/iterator_archetypes.hpp b/include/boost/iterator/iterator_archetypes.hpp new file mode 100644 index 0000000..09c3eba --- /dev/null +++ b/include/boost/iterator/iterator_archetypes.hpp @@ -0,0 +1,237 @@ +// (C) Copyright Jeremy Siek 2002. Permission to copy, use, modify, +// sell and distribute this software is granted provided this +// copyright notice appears in all copies. This software is provided +// "as is" without express or implied warranty, and with no claim as +// to its suitability for any purpose. + +#ifndef BOOST_ITERATOR_ARCHETYPES_HPP +#define BOOST_ITERATOR_ARCHETYPES_HPP + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +namespace boost +{ + + template + struct access_archetype; + + template + struct traversal_archetype; + + namespace detail { + + template + struct assign_proxy + { + assign_proxy& operator=(T); + }; + + template + struct read_write_proxy : + assign_proxy + { + operator T(); + }; + + template + struct arrow_proxy + { + T const* operator->() const; + }; + + struct no_operator_brackets {}; + + template + struct readable_operator_brackets + { + ValueType operator[](std::ptrdiff_t n) const; + }; + + template + struct writable_operator_brackets + { + read_write_proxy operator[](std::ptrdiff_t n) const; + }; + + template + struct operator_brackets : + mpl::if_< is_tag, + mpl::if_< is_tag, + writable_operator_brackets< Value >, + mpl::if_< is_tag, + readable_operator_brackets, + no_operator_brackets > >, + no_operator_brackets >::type + { + }; + + template + struct traversal_archetype_; + + template + struct traversal_archetype_ + { + typedef void difference_type; + + Derived& operator++(); + Derived operator++(int) const; + }; + + template + struct traversal_archetype_ + : public equality_comparable< traversal_archetype_ >, + public traversal_archetype_ + { + }; + + template + bool operator==(traversal_archetype_ const&, + traversal_archetype_ const&); + + template + struct traversal_archetype_ + : public traversal_archetype_ + { + typedef std::ptrdiff_t difference_type; + }; + + template + struct traversal_archetype_ + : public traversal_archetype_ + { + Derived& operator--(); + Derived operator--(int) const; + }; + + template + struct traversal_archetype_ + : public partially_ordered< traversal_archetype_ >, + public traversal_archetype_ + { + Derived& operator+=(std::ptrdiff_t); + Derived& operator-=(std::ptrdiff_t); + }; + + template + Derived& operator+(traversal_archetype_ const&, + std::ptrdiff_t); + + template + Derived& operator+(std::ptrdiff_t, + traversal_archetype_ const&); + + template + Derived& operator-(traversal_archetype_ const&, + std::ptrdiff_t); + + template + std::ptrdiff_t operator-(traversal_archetype_ const&, + traversal_archetype_ const&); + + template + bool operator<(traversal_archetype_ const&, + traversal_archetype_ const&); + + struct bogus_type; + + template + struct convertible_type + : mpl::if_< is_const, + typename remove_const::type, + bogus_type > + {}; + + } // namespace detail + + + template + struct access_archetype; + + template + struct access_archetype + { + typedef typename remove_cv::type value_type; + typedef Value reference; + typedef Value* pointer; + + value_type operator*() const; + + detail::arrow_proxy operator->() const; + }; + + template + struct access_archetype + { + BOOST_STATIC_ASSERT((!is_const::value)); + + typedef void value_type; + typedef void reference; + typedef void pointer; + + detail::assign_proxy operator*() const; + }; + + template + struct access_archetype : + public virtual access_archetype + { + typedef detail::read_write_proxy reference; + + detail::read_write_proxy operator*() const; + }; + + template + struct access_archetype : + public virtual access_archetype + { + typedef Value& reference; + + Value& operator*() const; + Value* operator->() const; + }; + + template + struct access_archetype + : public virtual access_archetype + { + BOOST_STATIC_ASSERT((!is_const::value)); + }; + + template + struct traversal_archetype + : detail::operator_brackets< typename remove_cv::type, + AccessCategory, + TraversalCategory >, + detail::traversal_archetype_ + { + }; + + template + struct iterator_archetype + : public traversal_archetype, Value, AccessCategory, TraversalCategory>, + public access_archetype + { + typedef iterator_tag iterator_category; + + iterator_archetype(); + iterator_archetype(iterator_archetype const&); + + iterator_archetype& operator=(iterator_archetype const&); + + // Optional conversion from mutable + // iterator_archetype(iterator_archetype::type, AccessCategory, TraversalCategory> const&); + }; + +} // namespace boost + + +#endif // BOOST_ITERATOR_ARCHETYPES_HPP