C++ Template Metaprogramming
Solutions to the exercises throughout the book
Loading...
Searching...
No Matches
exercise-3-1.hpp
Go to the documentation of this file.
1// ===-- chapter-3/exercise-3-1.hpp ----------------------- -*- C++ -*- --=== //
9#ifndef EXERCISE_3_1
10#define EXERCISE_3_1
11
12#include <boost/mpl/int.hpp>
13#include <boost/mpl/plus.hpp>
14#include <boost/mpl/transform.hpp>
15
16#include <boost/mpl/placeholders.hpp>
17using namespace boost::mpl::placeholders;
18
19
33namespace exercise_3_1 {
34
42{
44 template <typename T>
45 struct apply : boost::mpl::plus< T, boost::mpl::int_<1> > { };
46};
47
52template <typename T>
53struct ex_3_1 : boost::mpl::transform<T, ex_3_1apply > { };
54
59template <typename T>
60struct ex_3_1b
61 : boost::mpl::transform<
62 T,
63 boost::mpl::plus< _1, boost::mpl::int_<1> >
64 >
65{ };
66
67} // namespace exercise_3_1
68
69#endif // EXERCISE_3_1
Encapsulate solution for Exercise 3-1.
Add 1 to all items in a sequence (w/o placeholder args).
Metafunction to apply during transformation.
Add 1 to all items in a sequence (w/ placeholder args).