wrapped_forward_iterator.hh

00001 /* vim: set sw=4 sts=4 et foldmethod=syntax : */
00002 
00003 /*
00004  * Copyright (c) 2007, 2008 Ciaran McCreesh
00005  *
00006  * This file is part of the Paludis package manager. Paludis is free software;
00007  * you can redistribute it and/or modify it under the terms of the GNU General
00008  * Public License version 2, as published by the Free Software Foundation.
00009  *
00010  * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
00011  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00012  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
00013  * details.
00014  *
00015  * You should have received a copy of the GNU General Public License along with
00016  * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
00017  * Place, Suite 330, Boston, MA  02111-1307  USA
00018  */
00019 
00020 #ifndef PALUDIS_GUARD_PALUDIS_UTIL_WRAPPED_FORWARD_ITERATOR_HH
00021 #define PALUDIS_GUARD_PALUDIS_UTIL_WRAPPED_FORWARD_ITERATOR_HH 1
00022 
00023 #include <paludis/util/wrapped_forward_iterator-fwd.hh>
00024 #include <paludis/util/operators.hh>
00025 #include <paludis/util/attributes.hh>
00026 #include <tr1/functional>
00027 #include <tr1/type_traits>
00028 #include <iterator>
00029 
00030 #ifdef PALUDIS_HAVE_CONCEPTS
00031 #  include <concepts>
00032 #endif
00033 
00034 namespace paludis
00035 {
00036     /**
00037      * A WrappedForwardIterator is a generic wrapper around a forward iterator,
00038      * hiding the underlying base iterator.
00039      *
00040      * \ingroup g_iterator
00041      * \since 0.26
00042      */
00043     template <typename Tag_, typename Value_>
00044     class PALUDIS_VISIBLE WrappedForwardIterator :
00045         public equality_operators::HasEqualityOperators
00046     {
00047         private:
00048             struct Base;
00049             template <typename T_> struct BaseImpl;
00050 
00051             Base * _base;
00052 
00053         public:
00054             ///\name Basic operations
00055             ///\{
00056 
00057             WrappedForwardIterator();
00058             ~WrappedForwardIterator();
00059             WrappedForwardIterator(const WrappedForwardIterator &);
00060 
00061             template <typename T_>
00062             WrappedForwardIterator(const T_ &);
00063 
00064             WrappedForwardIterator & operator= (const WrappedForwardIterator &);
00065 
00066             ///\}
00067 
00068             ///\name Standard library typedefs
00069             ///\{
00070 
00071             typedef typename std::tr1::remove_reference<Value_>::type & value_type;
00072             typedef typename std::tr1::remove_reference<Value_>::type & reference;
00073             typedef typename std::tr1::remove_reference<Value_>::type * pointer;
00074             typedef std::ptrdiff_t difference_type;
00075             typedef std::forward_iterator_tag iterator_category;
00076 
00077             ///\}
00078 
00079             ///\name Increment
00080             ///\{
00081 
00082             WrappedForwardIterator & operator++ ();
00083             WrappedForwardIterator operator++ (int);
00084 
00085             ///\}
00086 
00087             ///\name Dereference
00088             ///\{
00089 
00090             pointer operator-> () const;
00091             reference operator* () const;
00092 
00093             ///\}
00094 
00095             ///\name Equality
00096             ///\{
00097 
00098             bool operator== (const WrappedForwardIterator &) const;
00099 
00100             ///\}
00101 
00102             ///\name Underlying iterator
00103             ///\{
00104 
00105             template <typename T_> T_ & underlying_iterator();
00106             template <typename T_> const T_ & underlying_iterator() const;
00107 
00108             ///\}
00109     };
00110 }
00111 
00112 #ifdef PALUDIS_HAVE_CONCEPTS
00113 namespace std
00114 {
00115     template <typename Tag_, typename Value_>
00116     concept_map ForwardIterator<paludis::WrappedForwardIterator<Tag_, Value_> >
00117     {
00118     };
00119 }
00120 #endif
00121 
00122 #endif

Generated on Mon Dec 22 19:43:51 2008 for paludis by  doxygen 1.5.7.1