00001 /* iterator_to_const and const_iterator_to_const class declarations. 00002 Copyright (C) 2001-2008 Roberto Bagnara <bagnara@cs.unipr.it> 00003 00004 This file is part of the Parma Polyhedra Library (PPL). 00005 00006 The PPL is free software; you can redistribute it and/or modify it 00007 under the terms of the GNU General Public License as published by the 00008 Free Software Foundation; either version 3 of the License, or (at your 00009 option) any later version. 00010 00011 The PPL is distributed in the hope that it will be useful, but WITHOUT 00012 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00013 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 00014 for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with this program; if not, write to the Free Software Foundation, 00018 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307, USA. 00019 00020 For the most up-to-date information see the Parma Polyhedra Library 00021 site: http://www.cs.unipr.it/ppl/ . */ 00022 00023 #ifndef PPL_iterator_to_const_hh 00024 #define PPL_iterator_to_const_hh 1 00025 00026 #include "iterator_to_const.types.hh" 00027 #include "Powerset.types.hh" 00028 //#include "Ask_Tell.types.hh" 00029 00030 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS 00032 00047 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS) 00048 template <typename Container> 00049 class Parma_Polyhedra_Library::iterator_to_const { 00050 private: 00052 typedef typename Container::iterator Base; 00053 00055 typedef typename 00056 std::iterator_traits<typename Container::const_iterator> Traits; 00057 00059 Base base; 00060 00062 iterator_to_const(const Base& b); 00063 00064 friend class const_iterator_to_const<Container>; 00065 template <typename T> friend class Powerset; 00066 //template <typename T> friend class Ask_Tell; 00067 00068 public: 00069 // Same traits of the const_iterator, therefore 00070 // forbidding the direct modification of sequence elements. 00071 typedef typename Traits::iterator_category iterator_category; 00072 typedef typename Traits::value_type value_type; 00073 typedef typename Traits::difference_type difference_type; 00074 typedef typename Traits::pointer pointer; 00075 typedef typename Traits::reference reference; 00076 00078 iterator_to_const(); 00079 00081 iterator_to_const(const iterator_to_const& y); 00082 00084 reference operator*() const; 00085 00087 pointer operator->() const; 00088 00090 iterator_to_const& operator++(); 00091 00093 iterator_to_const operator++(int); 00094 00096 iterator_to_const& operator--(); 00097 00099 iterator_to_const operator--(int); 00100 00105 bool operator==(const iterator_to_const& y) const; 00106 00111 bool operator!=(const iterator_to_const& y) const; 00112 }; 00113 00114 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS 00116 00121 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS) 00122 template <typename Container> 00123 class Parma_Polyhedra_Library::const_iterator_to_const { 00124 private: 00126 typedef typename Container::const_iterator Base; 00127 00129 typedef typename std::iterator_traits<Base> Traits; 00130 00132 Base base; 00133 00135 const_iterator_to_const(const Base& b); 00136 00137 friend class iterator_to_const<Container>; 00138 template <typename T> friend class Powerset; 00139 //template <typename T> friend class Ask_Tell; 00140 00141 public: 00142 // Same traits of the underlying const_iterator. 00143 typedef typename Traits::iterator_category iterator_category; 00144 typedef typename Traits::value_type value_type; 00145 typedef typename Traits::difference_type difference_type; 00146 typedef typename Traits::pointer pointer; 00147 typedef typename Traits::reference reference; 00148 00150 const_iterator_to_const(); 00151 00153 const_iterator_to_const(const const_iterator_to_const& y); 00154 00156 const_iterator_to_const(const iterator_to_const<Container>& y); 00157 00159 reference operator*() const; 00160 00162 pointer operator->() const; 00163 00165 const_iterator_to_const& operator++(); 00166 00168 const_iterator_to_const operator++(int); 00169 00171 const_iterator_to_const& operator--(); 00172 00174 const_iterator_to_const operator--(int); 00175 00180 bool operator==(const const_iterator_to_const& y) const; 00181 00186 bool operator!=(const const_iterator_to_const& y) const; 00187 }; 00188 00189 namespace Parma_Polyhedra_Library { 00190 00191 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS 00192 00198 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS) 00199 template <typename Container> 00200 bool 00201 operator==(const iterator_to_const<Container>& x, 00202 const const_iterator_to_const<Container>& y); 00203 00204 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS 00205 00211 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS) 00212 template <typename Container> 00213 bool 00214 operator!=(const iterator_to_const<Container>& x, 00215 const const_iterator_to_const<Container>& y); 00216 00217 } // namespace Parma_Polyhedra_Library 00218 00219 #include "iterator_to_const.inlines.hh" 00220 00221 #endif // !defined(PPL_iterator_to_const_hh)