wrapped_forward_iterator.hh

00001 /* vim: set sw=4 sts=4 et foldmethod=syntax : */
00002 
00003 /*
00004  * Copyright (c) 2007, 2008, 2009 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 namespace paludis
00031 {
00032     /**
00033      * A WrappedForwardIterator is a generic wrapper around a forward iterator,
00034      * hiding the underlying base iterator.
00035      *
00036      * \ingroup g_iterator
00037      * \since 0.26
00038      */
00039     template <typename Tag_, typename Value_>
00040     class PALUDIS_VISIBLE WrappedForwardIterator :
00041         public equality_operators::HasEqualityOperators
00042     {
00043         private:
00044             struct Base;
00045             template <typename T_> struct BaseImpl;
00046 
00047             Base * _base;
00048 
00049         public:
00050             ///\name Basic operations
00051             ///\{
00052 
00053             WrappedForwardIterator();
00054             ~WrappedForwardIterator();
00055             WrappedForwardIterator(const WrappedForwardIterator &);
00056 
00057             template <typename T_>
00058             WrappedForwardIterator(const T_ &);
00059 
00060             WrappedForwardIterator & operator= (const WrappedForwardIterator &);
00061 
00062             ///\}
00063 
00064             ///\name Standard library typedefs
00065             ///\{
00066 
00067             typedef typename std::tr1::remove_reference<Value_>::type & value_type;
00068             typedef typename std::tr1::remove_reference<Value_>::type & reference;
00069             typedef typename std::tr1::remove_reference<Value_>::type * pointer;
00070             typedef std::ptrdiff_t difference_type;
00071             typedef std::forward_iterator_tag iterator_category;
00072 
00073             ///\}
00074 
00075             ///\name Increment
00076             ///\{
00077 
00078             WrappedForwardIterator & operator++ ();
00079             WrappedForwardIterator operator++ (int);
00080 
00081             ///\}
00082 
00083             ///\name Dereference
00084             ///\{
00085 
00086             pointer operator-> () const;
00087             reference operator* () const;
00088 
00089             ///\}
00090 
00091             ///\name Equality
00092             ///\{
00093 
00094             bool operator== (const WrappedForwardIterator &) const;
00095 
00096             ///\}
00097 
00098             ///\name Underlying iterator
00099             ///\{
00100 
00101             template <typename T_> T_ & underlying_iterator();
00102             template <typename T_> const T_ & underlying_iterator() const;
00103 
00104             ///\}
00105     };
00106 }
00107 
00108 #endif

Generated on Mon Sep 21 10:36:08 2009 for paludis by  doxygen 1.5.4