? ? }
}
?
uint64_t test_accumulate_lambda()
{
? ? uint64_t x = 0;
? ? auto accumulator = [&x] (uint64_t i) { x += i;
?};
? ? do_test_loop(accumulator);
? ? return x;
}
?
void test_accumulate_bind_function(uint64_t& x, uint64_t i)
{
? ? x += i;
}
?
uint64_t test_accumulate_bind()
{
? ? namespace arg = std::placeholders;
? ??
? ? uint64_t x = 0;
? ? std::function accumulator = std::bind(&test_accumulate_bind_function, std::ref(x), arg::_1);
? ? do_test_loop(accumulator);
? ? return x;
}
?
uint64_t test_accumulate_bound_lambda()
{
? ? uint64_t x = 0;
? ? std::function accumulator = [&x] (uint64_t i) { x += i; };
? ? do_test_loop(accumulator);
? ? return x;
}
?
?
uint64_t test_accumulate_class_function()
{
? ? uint64_t x = 0;
?
? ? do_test_loop(FunctorClass(x));
? ?// for_each(v.begin(), v.end(), FunctorClass(x));
? ? return x;
}
?
uint64_t test_accumulate_bind_auto()
{
? ? namespace arg = std::placeholders;
? ??
? ? uint64_t x = 0;
? ? auto accumulator = std::bind(&test_accumulate_bind_function, std::ref(x), arg::_1);
? ? do_test_loop(accumulator);
? ? return x;
}
?
#if USE_BOOST
uint64_t test_accumulate_boost_bind()
{
? ? uint64_t x = 0;
? ??
? ? boost::function accumulator = boost::bind(&test_accumulate_bind_function, boost::ref(x), _1);
? ? do_test_loop(accumulator);
? ? return x;
}
?
uint64_t test_accumulate_boost_bound_lambda()
{
? ? uint64_t x = 0;
? ? boost::function accumulator = [&x] (uint64_t i) { x += i; };
? ? do_test_loop(accumulator);
? ? return x;
}
#endif
?
int main()
{
? ? if (!test_timer())
? ? {
? ? ? ? std::cout << "Failed timer test." << std::endl;
? ? ? ? return -1;
? ? }
? ??
? ? run_test("Accumulate (lambda) ? ? ? ? ? ?", &test_accumulate_lambda);
? ? run_test("Accumulate (bind) ? ? ? ? ? ? ?", &test_accumulate_bind);
? ? run_test("Accumulate (bound lambda) ? ? ?", &test_accumulate_bound_lambda);
? ? run_test("Accumulate (Function Object) ? ?", &test_accumulate_class_function);
? ? run_test("Accumulate (bind auto) ? ?", &test_accumulate_bind_auto);
#if USE_BOOST
? ? run_test("Accumulate (boost bind) ? ? ? ?", &test_accumulate_boost_bind);
? ? run_test("Accumulate (boost bound lambda)