Boost logo

Boost :

From: Aleksey Gurtovoy (agurtovoy_at_[hidden])
Date: 2003-01-03 06:16:13


David Abrahams wrote:
> Second thing: you can save yourself lots of typenames by taking
> advantage of the way MPL lets you pass an uninstantiated metafunction,
> without getting its nested ::type member, wherever a bool_c<...> is
> expected:

Uhm, that's not exactly correct. I would re-formulate it along these lines:

To reduce the notational overhead imposed by the specifics of the
compile-time domain, many of MPL metafunctions, when fully-curried (provided
with all arguments), directly support the interface of the Integral Constant
concept:

  BOOST_STATIC_ASSERT(not_equal_to< int_c<5>, int_c<0> >::type::value); //
OK, ordinary function invocation
  BOOST_STATIC_ASSERT(not_equal_to< int_c<5>, int_c<0> >::value); // also
OK!

This property often allows you to simplify your compile-time conditions:

>
> apply_if<
> typename equal_to<N, integral_c<N::value_type, 0> >::type
> , ...
>
> can be written:
>
> apply_if<
> equal_to<N, integral_c<N::value_type, 0> >
> , ...
>

Aleksey


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk