14#include <boost/static_assert.hpp>
16#include <boost/mpl/begin_end.hpp>
17#include <boost/mpl/deref.hpp>
18#include <boost/mpl/greater.hpp>
19#include <boost/mpl/iterator_tags.hpp>
20#include <boost/mpl/next_prior.hpp>
22#include <boost/type_traits/is_same.hpp>
83 typedef boost::mpl::forward_iterator_tag
category;
98template <
typename Cur,
typename Parent,
int VisitCount>
129 template <
typename S>
139 template <
typename Self,
typename Parent>
140 struct apply_on_iterator :
144 template <
typename Cur,
typename L,
typename R,
typename Parent>
145 struct apply_on_iterator<
chapter5::tree<Cur, L, R>, Parent>
148 exercise_5_10::inorder_view_iterator<
149 chapter5::tree<Cur, L, R>, Parent, 1>
153 template <
typename Parent>
154 struct apply_on_iterator<
chapter5::tree<>, Parent >
156 exercise_5_10::inorder_view< chapter5::tree<> > > { };
159 template <
typename S>
162 typename S::tree_root,
163 exercise_5_10::inorder_view_iterator_end
178template <
typename Cur,
typename Parent,
int VisitCount>
180 : boost::mpl::eval_if<
181 boost::is_same<exercise_5_10::inorder_view_iterator_end, Parent>,
182 exercise_5_10::inorder_view_iterator_end,
184 exercise_5_10::inorder_view_iterator<
185 typename Parent::current_tree,
186 typename Parent::parent_iterator,
191template <
typename Cur,
typename Parent>
196template <
typename Cur,
typename L,
typename R,
typename Parent,
int VisitCount>
198 chapter5::tree<Cur, L, R>, Parent, VisitCount> > { };
201template <
typename Cur,
typename L,
typename R,
typename Parent>
203 chapter5::tree<Cur, L, R>, Parent, 0> >
205 exercise_5_10::inorder_view_iterator<
207 exercise_5_10::inorder_view_iterator<
208 chapter5::tree<Cur, L, R>, Parent, 1>,
213template <
typename Cur,
typename R,
typename Parent>
215 chapter5::tree<Cur, void_, R>, Parent, 0> >
216 : next< exercise_5_10::inorder_view_iterator<
217 chapter5::tree<Cur, void_, R>, Parent, 1> > { };
219template <
typename Cur,
typename L,
typename R,
typename Parent>
221 chapter5::tree<Cur, L, R>, Parent, 1> >
223 chapter5::tree<Cur, L, R>, Parent, 2> { };
225template <
typename Cur,
typename L,
typename R,
typename Parent>
227 chapter5::tree<Cur, L, R>, Parent, 2> >
229 exercise_5_10::inorder_view_iterator<
231 exercise_5_10::inorder_view_iterator<
232 chapter5::tree<Cur, L, R>, Parent, 3>,
237template <
typename Cur,
typename L,
typename Parent>
239 chapter5::tree<Cur, L, void_>, Parent, 2> >
240 : next< exercise_5_10::inorder_view_iterator<
241 chapter5::tree<Cur, L, void_>, Parent, 3> > { };
244template <
typename Cur,
typename L,
typename R,
typename Parent>
246 chapter5::tree<Cur, L, R>, Parent, 3> >
247 : boost::mpl::eval_if<
248 boost::is_same<exercise_5_10::inorder_view_iterator_end, Parent>,
249 exercise_5_10::inorder_view_iterator_end,
251 exercise_5_10::inorder_view_iterator<
252 typename Parent::current_tree,
253 typename Parent::parent_iterator,
260template <
typename Cur,
typename Parent,
int VisitCount>
261struct deref<
exercise_5_10::inorder_view_iterator<Cur, Parent, VisitCount> >
267template <
typename Cur,
typename L,
typename R,
typename Parent,
int VisitCount>
269 chapter5::tree<Cur, L, R>, Parent, VisitCount> >
Define a binary tree structure for future exercises.
Exists to inject functionality into the Boost MPL namespace.
Exists to inject functionality into the Boost namespace.
Provide utilities availble to all Chapter 5 solutions.
Encapsulate solution for Exercise 5-10.
inorder_view_iterator< void_, void_, 0 > inorder_view_iterator_end
Establish an end to the sequence.
Establish an iterator to contain in-order traversal of the binary tree.
static int const visit_count
inorder_view_iterator< Cur, Parent, VisitCount > type
A tag for tag-dispatched sequence metafunctions.
Compels iterators to traverse the tree "in order".
boost::mpl::forward_iterator_tag category