Boost logo

Boost Users :

Subject: [Boost-users] [parameter] Composing ArgumentPacks
From: er (erwann.rogard_at_[hidden])
Date: 2009-04-12 17:27:05


Hi All,

Two argument packs can be composed with the comma operator. However, if
each ap is built using positional arguments, it doesn't seem to work, at
least as attempted in example (5) below. Any help would be appreciated.

BOOST_PARAMETER_KEYWORD(tag, x)
BOOST_PARAMETER_KEYWORD(tag, y)

template<class ArgumentPack>
void f(ArgumentPack const & args){
     double x_val = args[x];
     double y_val = args[y];
     std::cout
         << "x = " << x_val
         << ", y = " << y_val
         << std::endl;
}

int main()
{
     typedef boost::parameter::parameters<
         parameter::required<tag::x>,
         parameter::required<tag::y>
> spec_xy_t;

     double x_val = 9.0;
     double y_val = 0.1;

     f((y=y_val,x=x_val)); // (1)
     f(spec_xy_t()(x=9.0,y=0.1)); // (2)
     f(spec_xy_t()(x_val,y_val)); // (3)
     f( ( (y = y_val), (x = x_val) ) ); // (4)
     //OK so far

     spec_x_t spec_x;
     spec_y_t spec_y;
     f(
         ( spec_x(x_val),spec_y(y_val)) // (5)
     ); //no match operator[<unnamed>::x]

     return 0;
}


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