Boost logo

Boost :

From: Daniel Wallin (dalwan01_at_[hidden])
Date: 2003-02-02 17:17:07

At 16:48 2003-02-01 -0500, you wrote:
> > What do you mean by "a single framework could be used to handle both
> approaches"?
>I mean a library which would allow you to extract optional types
>parameters based on either their wrapper templates ("Color_is<...>")
>or on a predicate (e.g. pick the one for which is_class<T>::value is

Perhaps this can be done with the interface for
parameter extraction i posted earlier.. Something like:

template <typename T> struct Model_is;
template <typename T> struct Color_is;
template <typename T> struct Seats_is;
template <typename T> struct Transmission_is;

template <class Model = unspecified,
           class Color = unspecified,
           class Seats = unspecified,
           class Transmission = unspecified>
class car {

   typedef extract_policies<
       mpl::vector4<Model, Color, Seats, Transmission>
     , mpl::vector4<
         , named_parameter<Color_is>
         , named_parameter<Seats_is>
         , named_parameter<Transmission_is>
     , mpl::vector4<
         Model_is<gl>, Color_is<red>, Seats_is<leather>,
> policies_t;

   typedef typename policies_t::policy0 model;
   typedef typename policies_t::policy1 color;
   typedef typename policies_t::policy2 seats;
   typedef typename policies_t::policy3 transmission;


Where named_parameter<...> is sugar for is_same_tt<Model_is<void>, _1>
(from Jonathan's code). Obviously 'extract_policy' would be the wrong
name for this.. 'extract_parameters' would be more appropriate.

Daniel Wallin, dalwan01_at_[hidden]

Boost list run by bdawes at, gregod at, cpdaniel at, john at