00001
00002 #ifndef INSTIGATE_STL_ITERATOR_INTERFACE_HPP
00003 #define INSTIGATE_STL_ITERATOR_INTERFACE_HPP
00004
00050
00051 #include "concept.hpp"
00052
00053
00054
00055
00056 #include <iterator>
00057
00058
00059 namespace instigate {
00060 namespace stl {
00061 template <typename T>
00062 struct interface;
00063 template <typename T>
00064 struct interface<std::ostream_iterator<T> >;
00065 }
00066 }
00067
00078 template <typename T>
00079 struct instigate::stl::interface
00080 {
00085 typedef typename std::iterator_traits<T>::iterator_category
00086 iterator_category;
00087
00092 typedef typename std::iterator_traits<T>::value_type value_type;
00093
00098 typedef typename std::iterator_traits<T>::difference_type
00099 difference_type;
00105 static void increment(T& a)
00106 {
00107 ++a;
00108 }
00109
00115 static void decrement(T& a)
00116 {
00117 --a;
00118 }
00119
00128 static const value_type& const_dereference(const T& a)
00129 {
00130 return *a;
00131 }
00132
00139 static void advance(T& a, const difference_type& n)
00140 {
00141 a = a + n;
00142 }
00143
00152 static difference_type distance(const T& a, const T& b)
00153 {
00154 return b - a;
00155 }
00156
00163 static void dereference_assign(T a, const value_type& b)
00164 {
00165 *a = b;
00166 }
00167
00175 static value_type& dereference(const T& a)
00176 {
00177 return *a;
00178 }
00179 };
00180
00184 template<typename T>
00185 struct instigate::stl::interface<std::ostream_iterator<T> >
00186 {
00188 typedef T value_type;
00189
00196 static void dereference_assign(std::ostream_iterator<T> a,
00197 const value_type& b)
00198 {
00199 *a = b;
00200 }
00201 };
00202
00203
00204
00205 #endif // INSTIGATE_STL_ITERATOR_INTERFACE_HPP