12#include <boost/static_assert.hpp>
14#include <boost/mpl/accumulate.hpp>
15#include <boost/mpl/begin_end.hpp>
16#include <boost/mpl/deref.hpp>
17#include <boost/mpl/iterator_tags.hpp>
18#include <boost/mpl/next_prior.hpp>
19#include <boost/mpl/placeholders.hpp>
20#include <boost/mpl/plus.hpp>
21#include <boost/mpl/times.hpp>
22using namespace boost::mpl::placeholders;
60template <
unsigned long N>
struct binary;
72template <
unsigned long N>
79template <
unsigned long N>
89 template <
typename T>
struct apply { };
91 template <
unsigned long N>
102 template <
typename T>
struct apply { };
104 template <
unsigned long N>
130template <
unsigned long N>
147 template <
typename T1,
unsigned long N2>
151 typedef boost::mpl::plus<
152 boost::mpl::times< T1, boost::mpl::int_<2> >,
153 boost::mpl::int_<N2 % 10>
158 typedef typename boost::mpl::accumulate<
164 static int const value = type::value;
Exists to inject functionality into the Boost MPL namespace.
Exists to inject functionality into the Boost namespace.
Encapsulate solution for Exercise 6-1.
exercise_6_1::binary< N > type
exercise_6_1::binary< N > type
exercise_6_1::binary< 0 > type
exercise_6_1::binary< N/10 > type
boost::mpl::plus< boost::mpl::times< T1, boost::mpl::int_< 2 > >, boost::mpl::int_< N2 % 10 > > type
BOOST_STATIC_ASSERT((N2 % 10< 2))
Mathematics used by accumulate is broken out for clarity...
A tag for tag-dispatched sequence metafunctions.
Compile-time binary to decimal number translation.
boost::mpl::forward_iterator_tag category
static int const value
The computed result as a constant value.
boost::mpl::accumulate< binary< N >, boost::mpl::int_< 0 >, apply_binary_digit< _, _ > >::type type
Iterate across the digits, building a decimal result.