Boost Users :
From: Jonathan Turkanis (technews_at_[hidden])
Date: 2005-01-24 15:49:58
Brad Austin wrote:
> I wrote:
>> I recently purchased David Abrahams' and Aleksey Gurtovoy's new book
>> on the MPL, "C++ Template Metaprogramming" (obviously recently since
>> it's only been out a couple of weeks), and am working through some of
>> the examples. I'm having trouble with the factorial example in
>> 8.3.1, page 160:
>> #include <boost/mpl/int.hpp>
>> #include <boost/mpl/multiplies.hpp>
>> #include <boost/mpl/equal.hpp>
>> #include <boost/mpl/eval_if.hpp>
>> #include <boost/mpl/prior.hpp>
>> #include <boost/static_assert.hpp>
>> namespace mpl = boost::mpl;
>> template <class N>
>> struct factorial
>> : mpl::eval_if<
>> mpl::equal_to<N,mpl::int_<0> > // check N == 0
>> , mpl::int_<1> // 0! == 1
>> , mpl::multiplies< // N! == N * (N-1)!
>> , factorial<typename mpl::prior<N>::type>
>> BOOST_STATIC_ASSERT(N::value >= 0); // for nonnegative N
With the modified include directive, the code compiles fine for me on GCC
(MinGW) 3.2.x, 3.3.x and 3.4.x.
> Anyway, is this mailing list an appropriate place to bring up issues
> like this? I know David and Aleksey are members, but I'm not clear
> on whether their book qualifies as an official Boost product.
This is as good a place as any to bring up the question. You posted on a
weekend; now that it's over you should get an anser soon.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net