void foo(int a, int b, int c) { std::cout << a << " " << b << " " << c << std::endl; } int main() { int x = 1, y = 2, z = 3; CallArgsargs(x, y, z); args.call(foo); return 0; }
struct Bar { int x, y; Bar(int a, int b) : x(a), y(b) {}; void print() { std::cout << x << " " << y << std::endl; } }; int main() { Bar bar(1, 2); CallArgsIn this example, a struct called Bar is defined with two integer members and a function called `print` that prints their values to the console. An instance of Bar is created and passed to the CallArgs object, which calls the `print` method using the `&Bar::print` syntax. Package library: CallArgs is not a part of the standard C++ library, but it is a header-only library that can be easily included in your own code.args(bar); args.call(&Bar::print); return 0; }