|
Boost Users : |
Subject: [Boost-users] [parameter][mpl] How to do a union of ArgumentPacks?
From: Jesse Perla (jesseperla_at_[hidden])
Date: 2010-02-17 17:01:40
I would like to call a function using named parameters where I construct the
values from two different argument packs. How do I write a function that
will generically take the union of all of the named parameters? I am using
Intel C++ 11.1 with C++0X features turned on, so 'decltype' and 'auto' are
kosher, but not alternative function syntax. Also, the types I might have
in the args could be by value or reference or constant reference, so I can't
just copy them all by value.
Here is a simple example to see what I mean:
BOOST_PARAMETER_NAME(name1)
BOOST_PARAMETER_NAME(name2)
BOOST_PARAMETER_NAME(name3)
template<typename ArgPack>
double f(const ArgPack& args)
{
return args[_name1] + args[_name2] + args[_name3];
}
//Test using the argpack directly... this works fine.
std::cout << f(
(_name1 = 1.0, _name2 = 1.0, _name3 = 1.0)
);
//Now try to combine them:
template<typename ArgPack1, typename ArgPack2>
double g(const ArgPack1& args1, const ArgPack2& args2)
{
return f( parameter_union(args1, args2) ); //HOW DO I WRITE THE
parameter_union FUNCTION?
}
//usage
std::cout << g(
(_name1 = 1.0, _name2 = 1.0),
(_name3 = 1.0)
);
Thanks for your help,
Jesse
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