Boost logo

Boost Users :

Subject: Re: [Boost-users] [fusion] named parameter technique with fusion::map
From: Larry Evans (cppljevans_at_[hidden])
Date: 2010-11-09 08:28:49


On 11/09/10 05:02, Alfredo Correa wrote:
[snip]
> Another problem left is that in
> principle I could also use integer index to define the partial
> derivative parameter.
>
> clog << d<1>(h)( ... ) << endl; // derivative with respect to second
> (or first??) argument, i.e. equal to d<q>(h)(...)
>
> shouldn't be complicated since even if I used named parameters in a
> fusion map they can bereferenced by integer indeces.

With named parameters, IIUC, you have to declare a struct
for each argument. For example, for:

  double f( double height, double width, double depth);

you'd need:

  struct f_height{};
  struct f_width{};
  struct f_depth{};

What about using an enum instead:

  enum f_args
  { f_height
  , f_width
  , f_depty
  };

? In that case, there's no need for dereferencing an integer index and
the names(i.e. the enumerators) would be just as meaningful.

WARNING: not tested.

HTH.

-Larry


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