Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2006-02-02 08:26:25


"David A. Greene" <greened_at_[hidden]> writes:

> David Abrahams wrote:
>
>> I don't know if I told you this before, but it has been my intention,
>> and Danial Wallin's, to integrate such a facility with
>> Boost.Parameter, reusing much of the same code it already contains. I
>> think doing a whole separate implementation would be a huge waste.
>
> The implementation is done. It works. I have to fill out the
> documentation, which was waiting months due to some problems
> with BoostBook. The implementation has been done for quite a
> while. I don't consider it a waste at all.

It would be a waste to use separate code. Supporting NTP in
Boost.Parameter would only take a very few small changes, and we plan
to make them before the 1.34 freeze if possible.

> I looked at the Boost.Parameter implementation before but
> couldn't make heads or tails of it. We talked about
> Daniel doing some documentation but nothing came of it
> that I heard. If that's changed I'll be more than happy
> to look at integrating what I have. I do want to put up
> the current versions to get comments on the interfaces,
> at least.

I think if you look at what we're planning, maybe we can have a
productive debate about what the best interface is. A user
might do something like this:

  namespace parameter = boost::parameter;

  // Declare a named template parameter wrapper
  template <class T = void>
  struct value_type_is
    : parameter::named_template_parameter<value_type_is<>, T>
  {};

  template <class A0, class A1, class A2>
  struct foo
  {
      typedef parameter::parameters<
          value_type_is<> // more parameters listed here
> foo_parameters;

      typedef typename foo_parameters::bind<A0,A1,A2>::type args;

      // Extract the value_type; the default is int
      typedef typename parameter::binding<
        args, value_type_is<>, int
>::type value_type;
  };

  foo<float, .., ..>::type == float
  foo<value_type_is<float>, .., ..>::type == float

The beauty of this is that it will re-use all of the existing
capabilities of the library, like positional and unnamed arguments
(those that can be distinguished based on their properties and so
don't need to be tagged explicitly).

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com

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