#include <iostream>
#include <functional>
#include <utility>
void cb1(int a, double b, char c)
{
std::cout << "cb1( " << a << ", " << b << ", " << c << ")\n";
}
void cb2(const char* a, const char* b)
{
std::cout << "cb2( \"" << a << "\", \"" << b << "\")\n" ;
}
template <typename ...Args>
void mylibfun(int, int, std::function<void(Args...)>&& func, Args... args)
{
func(args...);
}
template <typename ...Args>
void mylibfun(int a, int b, void f(Args...), Args... args)
{
mylibfun(a, b, std::function<void(Args...)>(f), args...);
}
int main()
{
mylibfun(1, 2, cb1, 1, 2.0, 'c');
mylibfun(3, 4, cb2, "abc", "xyz") ;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8ZnVuY3Rpb25hbD4KI2luY2x1ZGUgPHV0aWxpdHk+Cgp2b2lkIGNiMShpbnQgYSwgZG91YmxlIGIsIGNoYXIgYykKewogICAgc3RkOjpjb3V0IDw8ICJjYjEoICIgPDwgYSA8PCAiLCAiIDw8IGIgPDwgIiwgIiA8PCBjIDw8ICIpXG4iOwp9Cgp2b2lkIGNiMihjb25zdCBjaGFyKiBhLCBjb25zdCBjaGFyKiBiKQp7CglzdGQ6OmNvdXQgPDwgImNiMiggXCIiIDw8IGEgPDwgIlwiLCBcIiIgPDwgYiA8PCAiXCIpXG4iIDsgCn0KCnRlbXBsYXRlIDx0eXBlbmFtZSAuLi5BcmdzPgp2b2lkIG15bGliZnVuKGludCwgaW50LCBzdGQ6OmZ1bmN0aW9uPHZvaWQoQXJncy4uLik+JiYgZnVuYywgQXJncy4uLiBhcmdzKQp7CiAgICBmdW5jKGFyZ3MuLi4pOwp9Cgp0ZW1wbGF0ZSA8dHlwZW5hbWUgLi4uQXJncz4Kdm9pZCBteWxpYmZ1bihpbnQgYSwgaW50IGIsIHZvaWQgZihBcmdzLi4uKSwgQXJncy4uLiBhcmdzKQp7CiAgICBteWxpYmZ1bihhLCBiLCBzdGQ6OmZ1bmN0aW9uPHZvaWQoQXJncy4uLik+KGYpLCBhcmdzLi4uKTsKfQoKaW50IG1haW4oKQp7CiAgICBteWxpYmZ1bigxLCAyLCBjYjEsIDEsIDIuMCwgJ2MnKTsKICAgIG15bGliZnVuKDMsIDQsIGNiMiwgImFiYyIsICJ4eXoiKSA7Cn0=