00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef TOOL_VALUED_ITERATOR_HH_
00023 # define TOOL_VALUED_ITERATOR_HH_
00024
00025 # include <boost/optional.hpp>
00026
00027 # include <wipal/tool/iterator.hh>
00028
00029 namespace tool
00030 {
00031
00032
00033
00034
00035
00036 template <class B>
00037 struct valued_iterator;
00038
00039
00040
00041
00042
00043
00045 template <class B>
00046 struct types< valued_iterator<B> >
00047 {
00049 typedef undefined_type value_type;
00050
00052 typedef undefined_type iterable_type;
00053 };
00054
00055
00056
00057
00058
00077 template <class Bottom>
00078 struct valued_iterator: wp_inherit(public iterator, valued_iterator<Bottom>)
00079 {
00080
00082
00083 typedef wp_get_exact(Bottom, valued_iterator<Bottom>) exact_type;
00084 typedef iterator<exact_type> super_type;
00085 typedef wp_type(value_type, exact_type) value_type;
00087
00089
00090 const value_type& get() const;
00091 value_type& get();
00093
00095
00096 const value_type* get_ptr() const;
00097 value_type* get_ptr();
00099
00100 protected:
00101
00103 ~valued_iterator();
00104
00106 typedef typename boost::optional<value_type> optional_value;
00107
00109
00110 const optional_value& value() const;
00111 optional_value& value();
00113
00114 private:
00115
00117 optional_value v_;
00118
00119 };
00120
00121 }
00122
00123 # include "valued_iterator.hxx"
00124
00125 #endif // ! TOOL_VALUED_ITERATOR_HH_