Allocation free function example
#include <iostream>
int test(int v)
{
return v + 100;
}
class Class
{
public:
int operator()(int v) { return v + 200; }
int test(int v) { return v + 300; }
static int static_test(int v) { return v + 400; }
};
int main(int argc, char** argv)
{
function = test;
std::cout << "test(11) = " << function(11) << std::endl;
Class instance;
function = instance;
std::cout << "Class::operator(22) = " << function(22) << std::endl;
function = std::bind(&Class::test, &instance, std::placeholders::_1);
std::cout << "Class::test(33) = " << function(33) << std::endl;
function = Class::static_test;
std::cout << "Class::static_test(44) = " << function(44) << std::endl;
auto lambda = [=](int v) { return v + 500; };
function = lambda;
std::cout << "lambda(55) = " << function(55) << std::endl;
return 0;
}
Allocation free function stub.
Allocation free function definition.