I have a function template with a variadic number of template parameters:
template <typename T1, typename... Ts>
void doSomething()
{
...
}
Furthermore I have an mpl set defined as follows:
template <typename... Ts>
struct MyContainerCreator
{
using type = boost::mpl::set<Ts...>;
};
using MyContainer= MyContainerCreator<T1, T2>;
Now I want to write a function doSomethingForAll() that calls doSomething() with the types in the mpl set as template parameters. Something like:
void doSomethingForAll()
{
//pseudocode:
doSomething<expandTypesToTemplateParameters<MyContainer::type>>();
}
Is this possible?
Essentially you want a lifting function that maps a
template<class...> class TTwith ampl::set<Ts...>toTT<Ts...>.To do this generically, write a
lifterwith the help of Foldable:Then you can use lift mpl container in this way:
Then
uisfoo<int, long>,visfoo<int, long>orfoo<long, int>depends onmplimplementation.With this tool, your task can be done by: