I'd like to use parameters pack, but find the problem. Some code:
template <typename Function, typename... Args>
auto f(Function func, Args... args) -> decltype(func(args...))
{
auto f11 = std::bind(func, args...);
f11();
}
void print(const char* string)
{
std::cout << string << std::endl;
}
All of this works well:
f([] (const char* additional, const char* more) {
std::cout << "hello ( " << additional << ", " << more << " )" << std::endl;
}, "additional text", "and one more");
auto printFunction = std::bind(&print, std::placeholders::_1);
printFunction("hello from print bind");
f(print, "hello from print directly");
but if i would like to give std::function to parameters pack:
f([] (std::function<void(const char*)> printParamFunc) {
printParamFunc("hello from print from std::function");
}, printFunction);
application no more compiles.
So, what the problem to use function as parameter in pack?
Thanks.
UPDATE: if change code of f to:
template <typename Function, typename... Args>
auto f(Function func, Args... args) -> decltype(func(args...))
{
func(args...);
}
it works well, but i wouldn't like to execute this function here, i wanna create function and pass it like param.
UPDATE2: Code execution example: http://ideone.com/gDjnPq
UPDATE3: Clear code with compilation error: http://ideone.com/50z7IN