00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef MTL_ITERATOR_ADAPTOR_DETAIL_INCLUDE
00013 #define MTL_ITERATOR_ADAPTOR_DETAIL_INCLUDE
00014
00015 namespace mtl { namespace utilities { namespace detail {
00016
00017
00018 template <typename Adaptor>
00019 struct adaptor_operators
00020 {
00021 Adaptor& operator++()
00022 {
00023 Adaptor& me = static_cast<Adaptor&>(*this);
00024 ++me.cursor;
00025 return me;
00026 }
00027
00028 Adaptor& operator++(int)
00029 {
00030 Adaptor& me = static_cast<Adaptor&>(*this);
00031 Adaptor tmp(me);
00032 ++me.cursor;
00033 return tmp;
00034 }
00035
00036 bool operator==(Adaptor const& x) const
00037 {
00038 Adaptor const& me = static_cast<Adaptor const&>(*this);
00039
00040
00041 return me.cursor == x.cursor;
00042
00043
00044
00045
00046
00047
00048
00049
00050 }
00051
00052 bool operator!=(Adaptor const& x) const
00053 {
00054 return !operator==(x);
00055 }
00056 };
00057
00058 template <typename Adaptor>
00059 struct ra_adaptor_operators
00060 : public adaptor_operators<Adaptor>
00061 {
00062 Adaptor operator+(int i) const
00063 {
00064 const Adaptor& me = static_cast<const Adaptor&>(*this);
00065 return Adaptor(me.map, me.cursor + i);
00066 }
00067
00068 Adaptor& operator+=(int i)
00069 {
00070 Adaptor& me = static_cast<Adaptor&>(*this);
00071 me.cursor+= i;
00072 return me;
00073 }
00074 };
00075
00076
00077
00078
00079 template <typename PropertyMap, typename Cursor, typename ValueType>
00080 struct const_iterator_proxy
00081 {
00082 const_iterator_proxy(PropertyMap map, Cursor cursor)
00083 : map(map), cursor(cursor) {}
00084
00085 operator ValueType() const
00086 {
00087 return map(*cursor);
00088 }
00089
00090 PropertyMap map;
00091 Cursor cursor;
00092 };
00093
00094
00095 template <typename PropertyMap, typename Cursor, typename ValueType>
00096 struct iterator_proxy
00097 {
00098 typedef iterator_proxy self;
00099
00100 iterator_proxy(PropertyMap map, Cursor cursor)
00101 : map(map), cursor(cursor) {}
00102
00103 operator ValueType() const
00104 {
00105 return map(*cursor);
00106 }
00107
00108 self& operator=(ValueType const& value)
00109 {
00110 map(*cursor, value);
00111 return *this;
00112 }
00113
00114 PropertyMap map;
00115 Cursor cursor;
00116 };
00117
00118 }}}
00119
00120 #endif // MTL_ITERATOR_ADAPTOR_DETAIL_INCLUDE