diff options
Diffstat (limited to 'vespalib')
-rw-r--r-- | vespalib/CMakeLists.txt | 1 | ||||
-rw-r--r-- | vespalib/src/tests/closure/.gitignore | 6 | ||||
-rw-r--r-- | vespalib/src/tests/closure/CMakeLists.txt | 15 | ||||
-rw-r--r-- | vespalib/src/tests/closure/autoclosurecaller_test.cpp | 42 | ||||
-rw-r--r-- | vespalib/src/tests/closure/closure_test.cpp | 257 | ||||
-rw-r--r-- | vespalib/src/tests/executor/executor_test.cpp | 9 | ||||
-rw-r--r-- | vespalib/src/vespa/vespalib/util/CMakeLists.txt | 1 | ||||
-rw-r--r-- | vespalib/src/vespa/vespalib/util/autoclosurecaller.h | 32 | ||||
-rw-r--r-- | vespalib/src/vespa/vespalib/util/closure.h | 1400 | ||||
-rw-r--r-- | vespalib/src/vespa/vespalib/util/closuretask.cpp | 13 | ||||
-rw-r--r-- | vespalib/src/vespa/vespalib/util/closuretask.h | 28 | ||||
-rw-r--r-- | vespalib/src/vespa/vespalib/util/overview.h | 7 |
12 files changed, 0 insertions, 1811 deletions
diff --git a/vespalib/CMakeLists.txt b/vespalib/CMakeLists.txt index a5e6b24abb2..92bb4f7622b 100644 --- a/vespalib/CMakeLists.txt +++ b/vespalib/CMakeLists.txt @@ -27,7 +27,6 @@ vespa_define_module( src/tests/box src/tests/btree src/tests/child_process - src/tests/closure src/tests/component src/tests/compress src/tests/compression diff --git a/vespalib/src/tests/closure/.gitignore b/vespalib/src/tests/closure/.gitignore deleted file mode 100644 index 9fa3ea2e68d..00000000000 --- a/vespalib/src/tests/closure/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -.depend -Makefile -autoclosurecaller_test -closure_test -vespalib_autoclosurecaller_test_app -vespalib_closure_test_app diff --git a/vespalib/src/tests/closure/CMakeLists.txt b/vespalib/src/tests/closure/CMakeLists.txt deleted file mode 100644 index 517048d0d91..00000000000 --- a/vespalib/src/tests/closure/CMakeLists.txt +++ /dev/null @@ -1,15 +0,0 @@ -# Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -vespa_add_executable(vespalib_closure_test_app TEST - SOURCES - closure_test.cpp - DEPENDS - vespalib -) -vespa_add_test(NAME vespalib_closure_test_app COMMAND vespalib_closure_test_app) -vespa_add_executable(vespalib_autoclosurecaller_test_app TEST - SOURCES - autoclosurecaller_test.cpp - DEPENDS - vespalib -) -vespa_add_test(NAME vespalib_autoclosurecaller_test_app COMMAND vespalib_autoclosurecaller_test_app) diff --git a/vespalib/src/tests/closure/autoclosurecaller_test.cpp b/vespalib/src/tests/closure/autoclosurecaller_test.cpp deleted file mode 100644 index ef523322553..00000000000 --- a/vespalib/src/tests/closure/autoclosurecaller_test.cpp +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - -#include <vespa/vespalib/testkit/testapp.h> -#include <vespa/vespalib/util/autoclosurecaller.h> - -using namespace vespalib; - -namespace { - -class Test : public vespalib::TestApp { - void requireThatClosureIsCalledInDtor(); - -public: - int Main() override; -}; - -int -Test::Main() -{ - TEST_INIT("autoclosurecaller_test"); - - TEST_DO(requireThatClosureIsCalledInDtor()); - - TEST_DONE(); -} - -void setBool(bool *b) { - *b = true; -} - -void Test::requireThatClosureIsCalledInDtor() { - bool is_called = false; - { - AutoClosureCaller caller(makeClosure(setBool, &is_called)); - EXPECT_TRUE(!is_called); - } - EXPECT_TRUE(is_called); -} - -} // namespace - -TEST_APPHOOK(Test); diff --git a/vespalib/src/tests/closure/closure_test.cpp b/vespalib/src/tests/closure/closure_test.cpp deleted file mode 100644 index 9faabb56fc5..00000000000 --- a/vespalib/src/tests/closure/closure_test.cpp +++ /dev/null @@ -1,257 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - -#include <vespa/vespalib/testkit/testapp.h> -#include <vespa/vespalib/util/closure.h> -#include <string> - -using std::shared_ptr; -using std::unique_ptr; -using namespace vespalib; - -namespace { - -class Test : public vespalib::TestApp { - void testClosure0_0(); - void testClosure0_1(); - void testClosure0_2(); - void testClosure1_0(); - void testClosure1_1(); - void testClosure1_2(); - void testMemberClosure0_0(); - void testMemberClosure0_1(); - void testMemberClosure0_2(); - void testMemberClosure1_0(); - void testMemberClosure1_1(); - void testMemberClosure1_2(); - -public: - int Main() override; -}; - -int -Test::Main() -{ - TEST_INIT("callback_test"); - - TEST_DO(testClosure0_0()); - TEST_DO(testClosure0_1()); - TEST_DO(testClosure0_2()); - TEST_DO(testClosure1_0()); - TEST_DO(testClosure1_1()); - TEST_DO(testClosure1_2()); - TEST_DO(testMemberClosure0_0()); - TEST_DO(testMemberClosure0_1()); - TEST_DO(testMemberClosure0_2()); - TEST_DO(testMemberClosure1_0()); - TEST_DO(testMemberClosure1_1()); - TEST_DO(testMemberClosure1_2()); - - TEST_DONE(); -} - -bool called = false; -void setCalled() { called = true; } -void setBool(bool *p) { *p = true; } -void setInt(int *p, int i) { *p = i; } -void setIntSum(int *p, int i, int j) { *p = i + j; } - -int setCalledReturnInt() { called = true; return 42; } -int setBoolReturnInt(bool *p) { *p = true; return 42; } -int setIntReturnInt(int *p, int i) { *p = i; return i; } -int setIntSumReturnInt(int *p, int i, int j) { *p = i + j; return i + j; } - -void Test::testClosure0_0() { - called = false; - unique_ptr<Closure> void_closure = makeClosure(setCalled); - void_closure->call(); - EXPECT_TRUE(called); - - called = false; - unique_ptr<Closure0<int> > closure = makeClosure(setCalledReturnInt); - EXPECT_EQUAL(42, closure->call()); - EXPECT_TRUE(called); -} - -void Test::testClosure0_1() { - bool is_called = false; - unique_ptr<Closure> void_closure = makeClosure(setBool, &is_called); - void_closure->call(); - EXPECT_TRUE(is_called); - - is_called = false; - unique_ptr<Closure0<int> > closure = - makeClosure(setBoolReturnInt, &is_called); - EXPECT_EQUAL(42, closure->call()); - EXPECT_TRUE(is_called); -} - -void Test::testClosure0_2() { - int i = 0; - unique_ptr<Closure> void_closure = makeClosure(setInt, &i, 42); - void_closure->call(); - EXPECT_EQUAL(42, i); - - unique_ptr<Closure0<int> > closure = makeClosure(setIntReturnInt, &i, 23); - EXPECT_EQUAL(23, closure->call()); - EXPECT_EQUAL(23, i); -} - -void Test::testClosure1_0() { - bool is_called = false; - unique_ptr<Closure1<bool *> > void_closure = makeClosure(setBool); - void_closure->call(&is_called); - EXPECT_TRUE(is_called); - - is_called = false; - unique_ptr<Closure1<bool *, int> > closure = makeClosure(setBoolReturnInt); - EXPECT_EQUAL(42, closure->call(&is_called)); - EXPECT_TRUE(is_called); -} - -void Test::testClosure1_1() { - int i = 0; - unique_ptr<Closure1<int> > void_closure = makeClosure(setInt, &i); - void_closure->call(42); - EXPECT_EQUAL(42, i); - - unique_ptr<Closure1<int, int> > closure = makeClosure(setIntReturnInt, &i); - EXPECT_EQUAL(23, closure->call(23)); - EXPECT_EQUAL(23, i); -} - -void Test::testClosure1_2() { - int i = 0; - unique_ptr<Closure1<int> > void_closure = makeClosure(setIntSum, &i, 42); - void_closure->call(8); - EXPECT_EQUAL(50, i); - - unique_ptr<Closure1<int, int> > closure = - makeClosure(setIntSumReturnInt, &i, 23); - EXPECT_EQUAL(42, closure->call(19)); - EXPECT_EQUAL(42, i); -} - - -struct MyObj { - bool is_called; - MyObj() : is_called(false) {} - - void setCalled() { is_called = true; } - void setBool(bool *p) { *p = true; } - void setInt(int *p, int i) { *p = i; } - void setInt3Arg(int *p, int i, string) { *p = i; } - - string message() { return "Hello world"; } - int twice(int i) { return 2 * i; } - double multiply(double x, double y) { return x * y; } - int sum(int a, int b, int c) { return a + b + c; } -}; - -void Test::testMemberClosure0_0() { - MyObj obj; - unique_ptr<Closure0<string> > closure = makeClosure(&obj, &MyObj::message); - EXPECT_EQUAL("Hello world", closure->call()); - - unique_ptr<Closure> void_closure = makeClosure(&obj, &MyObj::setCalled); - void_closure->call(); - EXPECT_TRUE(obj.is_called); - - shared_ptr<MyObj> obj_sp(new MyObj); - void_closure = makeClosure(obj_sp, &MyObj::setCalled); - void_closure->call(); - EXPECT_TRUE(obj_sp->is_called); -} - -void Test::testMemberClosure0_1() { - MyObj obj; - unique_ptr<Closure0<int> > closure = makeClosure(&obj, &MyObj::twice, 21); - EXPECT_EQUAL(42, closure->call()); - - bool is_called = false; - unique_ptr<Closure> void_closure = - makeClosure(&obj, &MyObj::setBool, &is_called); - void_closure->call(); - EXPECT_TRUE(is_called); - - is_called = false; - shared_ptr<MyObj> obj_sp(new MyObj); - void_closure = makeClosure(obj_sp, &MyObj::setBool, &is_called); - void_closure->call(); - EXPECT_TRUE(is_called); -} - -void Test::testMemberClosure0_2() { - MyObj obj; - unique_ptr<Closure0<double> > closure = - makeClosure(&obj, &MyObj::multiply, 1.5, 2.5); - EXPECT_APPROX(3.75, closure->call(), 0.001); - - int i = 0; - unique_ptr<Closure> void_closure = makeClosure(&obj, &MyObj::setInt, &i, 42); - void_closure->call(); - EXPECT_EQUAL(42, i); - - shared_ptr<MyObj> obj_sp(new MyObj); - void_closure = makeClosure(obj_sp, &MyObj::setInt, &i, 21); - void_closure->call(); - EXPECT_EQUAL(21, i); -} - - -void Test::testMemberClosure1_0() { - MyObj obj; - unique_ptr<Closure1<int, int> > closure = makeClosure(&obj, &MyObj::twice); - EXPECT_EQUAL(8, closure->call(4)); - - bool is_called = false; - unique_ptr<Closure1<bool *, void> > void_closure = - makeClosure(&obj, &MyObj::setBool); - void_closure->call(&is_called); - EXPECT_TRUE(is_called); - - is_called = false; - shared_ptr<MyObj> obj_sp(new MyObj); - void_closure = makeClosure(obj_sp, &MyObj::setBool); - void_closure->call(&is_called); - EXPECT_TRUE(is_called); -} - -void Test::testMemberClosure1_1() { - MyObj obj; - unique_ptr<Closure1<double, double> > closure = - makeClosure(&obj, &MyObj::multiply, 1.5); - EXPECT_APPROX(3.15, closure->call(2.1), 0.001); - - int i = 0; - unique_ptr<Closure1<int, void> > void_closure = - makeClosure(&obj, &MyObj::setInt, &i); - void_closure->call(42); - EXPECT_EQUAL(42, i); - - shared_ptr<MyObj> obj_sp(new MyObj); - void_closure = makeClosure(obj_sp, &MyObj::setInt, &i); - void_closure->call(21); - EXPECT_EQUAL(21, i); -} - -void Test::testMemberClosure1_2() { - MyObj obj; - unique_ptr<Closure1<int, int> > closure = - makeClosure(&obj, &MyObj::sum, 1, 2); - EXPECT_EQUAL(6, closure->call(3)); - - int i = 0; - unique_ptr<Closure1<string, void> > void_closure = - makeClosure(&obj, &MyObj::setInt3Arg, &i, 23); - void_closure->call("hello"); - EXPECT_EQUAL(23, i); - - unique_ptr<MyObj> obj_sp(new MyObj); - void_closure = makeClosure(std::move(obj_sp), &MyObj::setInt3Arg, &i, 42); - void_closure->call("world"); - EXPECT_EQUAL(42, i); -} - -} // namespace - -TEST_APPHOOK(Test); diff --git a/vespalib/src/tests/executor/executor_test.cpp b/vespalib/src/tests/executor/executor_test.cpp index 942b425be72..f6d3a4b5e1d 100644 --- a/vespalib/src/tests/executor/executor_test.cpp +++ b/vespalib/src/tests/executor/executor_test.cpp @@ -1,7 +1,6 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include <vespa/vespalib/testkit/testapp.h> -#include <vespa/vespalib/util/closuretask.h> #include <vespa/vespalib/util/lambdatask.h> #include <vespa/vespalib/util/executor_stats.h> @@ -9,14 +8,6 @@ using namespace vespalib; void setBool(bool *b) { *b = true; } -TEST("require that closures can be wrapped as tasks") { - bool called = false; - Executor::Task::UP task = makeTask(makeClosure(setBool, &called)); - EXPECT_TRUE(!called); - task->run(); - EXPECT_TRUE(called); -} - TEST("require that lambdas can be wrapped as tasks") { bool called = false; Executor::Task::UP task = makeLambdaTask([&called]() { called = true; }); diff --git a/vespalib/src/vespa/vespalib/util/CMakeLists.txt b/vespalib/src/vespa/vespalib/util/CMakeLists.txt index 22fbe0a95f6..1e3f7dc44e7 100644 --- a/vespalib/src/vespa/vespalib/util/CMakeLists.txt +++ b/vespalib/src/vespa/vespalib/util/CMakeLists.txt @@ -14,7 +14,6 @@ vespa_add_library(vespalib_vespalib_util OBJECT box.cpp child_process.cpp classname.cpp - closuretask.cpp compress.cpp compressor.cpp destructor_callbacks.cpp diff --git a/vespalib/src/vespa/vespalib/util/autoclosurecaller.h b/vespalib/src/vespa/vespalib/util/autoclosurecaller.h deleted file mode 100644 index 4faf695d621..00000000000 --- a/vespalib/src/vespa/vespalib/util/autoclosurecaller.h +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - -#pragma once - -#include "closure.h" - -namespace vespalib { - -/** - * @brief RAII class that calls a closure in its destructor. - * - * To make sure a closure is called when a scope is exited, an - * instance of this class can be kept on the stack. - */ -class AutoClosureCaller { - std::unique_ptr<Closure> _closure; - -public: - /** - * Creates a guard object that will call a closure on destruction. - * @param closure closure to call - */ - AutoClosureCaller(std::unique_ptr<Closure> closure) : _closure(std::move(closure)) {} - - /** - * Calls the registered closure. - */ - ~AutoClosureCaller() { _closure->call(); } -}; - -} // namespace proton - diff --git a/vespalib/src/vespa/vespalib/util/closure.h b/vespalib/src/vespa/vespalib/util/closure.h deleted file mode 100644 index 65e2064f1f9..00000000000 --- a/vespalib/src/vespa/vespalib/util/closure.h +++ /dev/null @@ -1,1400 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -// This file was generated by the gen_closure.py script. - -#pragma once - -#include <memory> - -namespace vespalib { - -// Interfaces ----------------------------------------------------------------- - -/** Interface of closures that take no arguments. */ -template <typename R = void> -struct Closure0 { - typedef std::unique_ptr<Closure0<R> > UP; - - virtual ~Closure0() {} - - virtual R call() = 0; -}; -typedef Closure0<void> Closure; - -/** Interface of closures that take one argument. */ -template <typename P1, typename R = void> -struct Closure1 { - typedef std::unique_ptr<Closure1<P1, R> > UP; - - virtual ~Closure1() {} - - virtual R call(P1 param1) = 0; -}; - -/** Interface of closures that take two arguments. */ -template <typename P1, typename P2, typename R = void> -struct Closure2 { - typedef std::unique_ptr<Closure2<P1, P2, R> > UP; - - virtual ~Closure2() {} - - virtual R call(P1 param1, P2 param2) = 0; -}; - -/** Interface of closures that take three arguments. */ -template <typename P1, typename P2, typename P3, typename R = void> -struct Closure3 { - typedef std::unique_ptr<Closure3<P1, P2, P3, R> > UP; - - virtual ~Closure3() {} - - virtual R call(P1 param1, P2 param2, P3 param3) = 0; -}; - -/** Interface of closures that take four arguments. */ -template <typename P1, typename P2, typename P3, typename P4, typename R = void> -struct Closure4 { - typedef std::unique_ptr<Closure4<P1, P2, P3, P4, R> > UP; - - virtual ~Closure4() {} - - virtual R call(P1 param1, P2 param2, P3 param3, P4 param4) = 0; -}; - -// Closure0 ------------------------------------------------------------------- - -/** Implementation of Closure0 binding no arguments to a free function. */ -template <typename R> -class Closure0_0 : public Closure0<R> { - typedef R (*Func)(); - - Func _func; - - virtual R call() override - { return _func(); } - -public: - Closure0_0(Func func) - : _func(func) {} -}; - -/** Implementation of Closure0 binding one argument to a free function. */ -template <typename T1, typename R> -class Closure0_1 : public Closure0<R> { - typedef R (*Func)(T1); - - Func _func; - T1 _arg1; - - virtual R call() override - { return _func(std::move(_arg1)); } - -public: - Closure0_1(Func func, T1 &&arg1) - : _func(func), _arg1(std::move(arg1)) {} -}; - -/** Implementation of Closure0 binding two arguments to a free function. */ -template <typename T1, typename T2, typename R> -class Closure0_2 : public Closure0<R> { - typedef R (*Func)(T1, T2); - - Func _func; - T1 _arg1; - T2 _arg2; - - R call() override { return _func(std::move(_arg1), std::move(_arg2)); } -public: - Closure0_2(Func func, T1 &&arg1, T2 &&arg2) - : _func(func), _arg1(std::move(arg1)), _arg2(std::move(arg2)) {} -}; - -/** Implementation of Closure0 binding three arguments to a free function. */ -template <typename T1, typename T2, typename T3, typename R> -class Closure0_3 : public Closure0<R> { - typedef R (*Func)(T1, T2, T3); - - Func _func; - T1 _arg1; - T2 _arg2; - T3 _arg3; - - R call() override { return _func(std::move(_arg1), std::move(_arg2), std::move(_arg3)); } - -public: - Closure0_3(Func func, T1 &&arg1, T2 &&arg2, T3 &&arg3) - : _func(func), _arg1(std::move(arg1)), _arg2(std::move(arg2)), _arg3(std::move(arg3)) {} -}; - -/** Implementation of Closure0 binding four arguments to a free function. */ -template <typename T1, typename T2, typename T3, typename T4, typename R> -class Closure0_4 : public Closure0<R> { - typedef R (*Func)(T1, T2, T3, T4); - - Func _func; - T1 _arg1; - T2 _arg2; - T3 _arg3; - T4 _arg4; - - virtual R call() override - { return _func(std::move(_arg1), std::move(_arg2), std::move(_arg3), std::move(_arg4)); } - -public: - Closure0_4(Func func, T1 &&arg1, T2 &&arg2, T3 &&arg3, T4 &&arg4) - : _func(func), _arg1(std::move(arg1)), _arg2(std::move(arg2)), _arg3(std::move(arg3)), _arg4(std::move(arg4)) {} -}; - -// MemberClosure0 ------------------------------------------------------------- - -/** Implementation of Closure0 binding no arguments to a member function. */ -template <class Ptr, class Obj, typename R> -class MemberClosure0_0 : public Closure0<R> { - typedef R (Obj::*MemFun)(); - - Ptr _ptr; - MemFun _mem_fun; - - virtual R call() override - { return ((*_ptr).*_mem_fun)(); } - -public: - MemberClosure0_0(Ptr ptr, MemFun mem_fun) - : _ptr(std::move(ptr)), _mem_fun(mem_fun) {} -}; - -/** Implementation of Closure0 binding one argument to a member function. */ -template <class Ptr, class Obj, typename T1, typename R> -class MemberClosure0_1 : public Closure0<R> { - typedef R (Obj::*MemFun)(T1); - - Ptr _ptr; - MemFun _mem_fun; - T1 _arg1; - - R call() override { return ((*_ptr).*_mem_fun)(std::move(_arg1)); } - -public: - MemberClosure0_1(Ptr ptr, MemFun mem_fun, T1 arg1) - : _ptr(std::move(ptr)), _mem_fun(mem_fun), _arg1(std::move(arg1)) {} -}; - -/** Implementation of Closure0 binding two arguments to a member function. */ -template <class Ptr, class Obj, typename T1, typename T2, typename R> -class MemberClosure0_2 : public Closure0<R> { - typedef R (Obj::*MemFun)(T1, T2); - - Ptr _ptr; - MemFun _mem_fun; - T1 _arg1; - T2 _arg2; - - R call() override { return ((*_ptr).*_mem_fun)(std::move(_arg1), std::move(_arg2)); } - -public: - MemberClosure0_2(Ptr ptr, MemFun mem_fun, T1 arg1, T2 arg2) - : _ptr(std::move(ptr)), _mem_fun(mem_fun), _arg1(std::move(arg1)), _arg2(std::move(arg2)) {} -}; - -/** Implementation of Closure0 binding three arguments to a member function. */ -template <class Ptr, class Obj, typename T1, typename T2, typename T3, typename R> -class MemberClosure0_3 : public Closure0<R> { - typedef R (Obj::*MemFun)(T1, T2, T3); - - Ptr _ptr; - MemFun _mem_fun; - T1 _arg1; - T2 _arg2; - T3 _arg3; - - virtual R call() override - { return ((*_ptr).*_mem_fun)(std::move(_arg1), std::move(_arg2), std::move(_arg3)); } - -public: - MemberClosure0_3(Ptr ptr, MemFun mem_fun, T1 arg1, T2 arg2, T3 arg3) - : _ptr(std::move(ptr)), _mem_fun(mem_fun), _arg1(std::move(arg1)), _arg2(std::move(arg2)), _arg3(std::move(arg3)) {} -}; - -/** Implementation of Closure0 binding four arguments to a member function. */ -template <class Ptr, class Obj, typename T1, typename T2, typename T3, typename T4, typename R> -class MemberClosure0_4 : public Closure0<R> { - typedef R (Obj::*MemFun)(T1, T2, T3, T4); - - Ptr _ptr; - MemFun _mem_fun; - T1 _arg1; - T2 _arg2; - T3 _arg3; - T4 _arg4; - - virtual R call() override - { return ((*_ptr).*_mem_fun)(std::move(_arg1), std::move(_arg2), std::move(_arg3), std::move(_arg4)); } - -public: - MemberClosure0_4(Ptr ptr, MemFun mem_fun, T1 arg1, T2 arg2, T3 arg3, T4 arg4) - : _ptr(std::move(ptr)), _mem_fun(mem_fun), _arg1(std::move(arg1)), _arg2(std::move(arg2)), _arg3(std::move(arg3)), _arg4(std::move(arg4)) {} -}; - -// Closure1 ------------------------------------------------------------------- - -/** Implementation of Closure1 binding no arguments to a free function. */ -template <typename P1, typename R> -class Closure1_0 : public Closure1<P1, R> { - typedef R (*Func)(P1); - - Func _func; - - virtual R call(P1 param1) override - { return _func(std::move(param1)); } - -public: - Closure1_0(Func func) - : _func(func) {} -}; - -/** Implementation of Closure1 binding one argument to a free function. */ -template <typename T1, typename P1, typename R> -class Closure1_1 : public Closure1<P1, R> { - typedef R (*Func)(T1, P1); - - Func _func; - T1 _arg1; - - virtual R call(P1 param1) override - { return _func(std::move(_arg1), std::move(param1)); } - -public: - Closure1_1(Func func, T1 &&arg1) - : _func(func), _arg1(std::move(arg1)) {} -}; - -/** Implementation of Closure1 binding two arguments to a free function. */ -template <typename T1, typename T2, typename P1, typename R> -class Closure1_2 : public Closure1<P1, R> { - typedef R (*Func)(T1, T2, P1); - - Func _func; - T1 _arg1; - T2 _arg2; - - virtual R call(P1 param1) override - { return _func(std::move(_arg1), std::move(_arg2), std::move(param1)); } - -public: - Closure1_2(Func func, T1 &&arg1, T2 &&arg2) - : _func(func), _arg1(std::move(arg1)), _arg2(std::move(arg2)) {} -}; - -/** Implementation of Closure1 binding three arguments to a free function. */ -template <typename T1, typename T2, typename T3, typename P1, typename R> -class Closure1_3 : public Closure1<P1, R> { - typedef R (*Func)(T1, T2, T3, P1); - - Func _func; - T1 _arg1; - T2 _arg2; - T3 _arg3; - - virtual R call(P1 param1) override - { return _func(std::move(_arg1), std::move(_arg2), std::move(_arg3), std::move(param1)); } - -public: - Closure1_3(Func func, T1 &&arg1, T2 &&arg2, T3 &&arg3) - : _func(func), _arg1(std::move(arg1)), _arg2(std::move(arg2)), _arg3(std::move(arg3)) {} -}; - -/** Implementation of Closure1 binding four arguments to a free function. */ -template <typename T1, typename T2, typename T3, typename T4, typename P1, typename R> -class Closure1_4 : public Closure1<P1, R> { - typedef R (*Func)(T1, T2, T3, T4, P1); - - Func _func; - T1 _arg1; - T2 _arg2; - T3 _arg3; - T4 _arg4; - - virtual R call(P1 param1) override - { return _func(std::move(_arg1), std::move(_arg2), std::move(_arg3), std::move(_arg4), std::move(param1)); } - -public: - Closure1_4(Func func, T1 &&arg1, T2 &&arg2, T3 &&arg3, T4 &&arg4) - : _func(func), _arg1(std::move(arg1)), _arg2(std::move(arg2)), _arg3(std::move(arg3)), _arg4(std::move(arg4)) {} -}; - -// MemberClosure1 ------------------------------------------------------------- - -/** Implementation of Closure1 binding no arguments to a member function. */ -template <class Ptr, class Obj, typename P1, typename R> -class MemberClosure1_0 : public Closure1<P1, R> { - typedef R (Obj::*MemFun)(P1); - - Ptr _ptr; - MemFun _mem_fun; - - virtual R call(P1 param1) override - { return ((*_ptr).*_mem_fun)(std::move(param1)); } - -public: - MemberClosure1_0(Ptr ptr, MemFun mem_fun) - : _ptr(std::move(ptr)), _mem_fun(mem_fun) {} -}; - -/** Implementation of Closure1 binding one argument to a member function. */ -template <class Ptr, class Obj, typename T1, typename P1, typename R> -class MemberClosure1_1 : public Closure1<P1, R> { - typedef R (Obj::*MemFun)(T1, P1); - - Ptr _ptr; - MemFun _mem_fun; - T1 _arg1; - - virtual R call(P1 param1) override - { return ((*_ptr).*_mem_fun)(std::move(_arg1), std::move(param1)); } - -public: - MemberClosure1_1(Ptr ptr, MemFun mem_fun, T1 arg1) - : _ptr(std::move(ptr)), _mem_fun(mem_fun), _arg1(std::move(arg1)) {} -}; - -/** Implementation of Closure1 binding two arguments to a member function. */ -template <class Ptr, class Obj, typename T1, typename T2, typename P1, typename R> -class MemberClosure1_2 : public Closure1<P1, R> { - typedef R (Obj::*MemFun)(T1, T2, P1); - - Ptr _ptr; - MemFun _mem_fun; - T1 _arg1; - T2 _arg2; - - virtual R call(P1 param1) override - { return ((*_ptr).*_mem_fun)(std::move(_arg1), std::move(_arg2), std::move(param1)); } - -public: - MemberClosure1_2(Ptr ptr, MemFun mem_fun, T1 arg1, T2 arg2) - : _ptr(std::move(ptr)), _mem_fun(mem_fun), _arg1(std::move(arg1)), _arg2(std::move(arg2)) {} -}; - -/** Implementation of Closure1 binding three arguments to a member function. */ -template <class Ptr, class Obj, typename T1, typename T2, typename T3, typename P1, typename R> -class MemberClosure1_3 : public Closure1<P1, R> { - typedef R (Obj::*MemFun)(T1, T2, T3, P1); - - Ptr _ptr; - MemFun _mem_fun; - T1 _arg1; - T2 _arg2; - T3 _arg3; - - virtual R call(P1 param1) override - { return ((*_ptr).*_mem_fun)(std::move(_arg1), std::move(_arg2), std::move(_arg3), std::move(param1)); } - -public: - MemberClosure1_3(Ptr ptr, MemFun mem_fun, T1 arg1, T2 arg2, T3 arg3) - : _ptr(std::move(ptr)), _mem_fun(mem_fun), _arg1(std::move(arg1)), _arg2(std::move(arg2)), _arg3(std::move(arg3)) {} -}; - -/** Implementation of Closure1 binding four arguments to a member function. */ -template <class Ptr, class Obj, typename T1, typename T2, typename T3, typename T4, typename P1, typename R> -class MemberClosure1_4 : public Closure1<P1, R> { - typedef R (Obj::*MemFun)(T1, T2, T3, T4, P1); - - Ptr _ptr; - MemFun _mem_fun; - T1 _arg1; - T2 _arg2; - T3 _arg3; - T4 _arg4; - - virtual R call(P1 param1) override - { return ((*_ptr).*_mem_fun)(std::move(_arg1), std::move(_arg2), std::move(_arg3), std::move(_arg4), std::move(param1)); } - -public: - MemberClosure1_4(Ptr ptr, MemFun mem_fun, T1 arg1, T2 arg2, T3 arg3, T4 arg4) - : _ptr(std::move(ptr)), _mem_fun(mem_fun), _arg1(std::move(arg1)), _arg2(std::move(arg2)), _arg3(std::move(arg3)), _arg4(std::move(arg4)) {} -}; - -// Closure2 ------------------------------------------------------------------- - -/** Implementation of Closure2 binding no arguments to a free function. */ -template <typename P1, typename P2, typename R> -class Closure2_0 : public Closure2<P1, P2, R> { - typedef R (*Func)(P1, P2); - - Func _func; - - virtual R call(P1 param1, P2 param2) override - { return _func(std::move(param1), std::move(param2)); } - -public: - Closure2_0(Func func) - : _func(func) {} -}; - -/** Implementation of Closure2 binding one argument to a free function. */ -template <typename T1, typename P1, typename P2, typename R> -class Closure2_1 : public Closure2<P1, P2, R> { - typedef R (*Func)(T1, P1, P2); - - Func _func; - T1 _arg1; - - virtual R call(P1 param1, P2 param2) override - { return _func(std::move(_arg1), std::move(param1), std::move(param2)); } - -public: - Closure2_1(Func func, T1 &&arg1) - : _func(func), _arg1(std::move(arg1)) {} -}; - -/** Implementation of Closure2 binding two arguments to a free function. */ -template <typename T1, typename T2, typename P1, typename P2, typename R> -class Closure2_2 : public Closure2<P1, P2, R> { - typedef R (*Func)(T1, T2, P1, P2); - - Func _func; - T1 _arg1; - T2 _arg2; - - virtual R call(P1 param1, P2 param2) override - { return _func(std::move(_arg1), std::move(_arg2), std::move(param1), std::move(param2)); } - -public: - Closure2_2(Func func, T1 &&arg1, T2 &&arg2) - : _func(func), _arg1(std::move(arg1)), _arg2(std::move(arg2)) {} -}; - -/** Implementation of Closure2 binding three arguments to a free function. */ -template <typename T1, typename T2, typename T3, typename P1, typename P2, typename R> -class Closure2_3 : public Closure2<P1, P2, R> { - typedef R (*Func)(T1, T2, T3, P1, P2); - - Func _func; - T1 _arg1; - T2 _arg2; - T3 _arg3; - - virtual R call(P1 param1, P2 param2) override - { return _func(std::move(_arg1), std::move(_arg2), std::move(_arg3), std::move(param1), std::move(param2)); } - -public: - Closure2_3(Func func, T1 &&arg1, T2 &&arg2, T3 &&arg3) - : _func(func), _arg1(std::move(arg1)), _arg2(std::move(arg2)), _arg3(std::move(arg3)) {} -}; - -/** Implementation of Closure2 binding four arguments to a free function. */ -template <typename T1, typename T2, typename T3, typename T4, typename P1, typename P2, typename R> -class Closure2_4 : public Closure2<P1, P2, R> { - typedef R (*Func)(T1, T2, T3, T4, P1, P2); - - Func _func; - T1 _arg1; - T2 _arg2; - T3 _arg3; - T4 _arg4; - - virtual R call(P1 param1, P2 param2) override - { return _func(std::move(_arg1), std::move(_arg2), std::move(_arg3), std::move(_arg4), std::move(param1), std::move(param2)); } - -public: - Closure2_4(Func func, T1 &&arg1, T2 &&arg2, T3 &&arg3, T4 &&arg4) - : _func(func), _arg1(std::move(arg1)), _arg2(std::move(arg2)), _arg3(std::move(arg3)), _arg4(std::move(arg4)) {} -}; - -// MemberClosure2 ------------------------------------------------------------- - -/** Implementation of Closure2 binding no arguments to a member function. */ -template <class Ptr, class Obj, typename P1, typename P2, typename R> -class MemberClosure2_0 : public Closure2<P1, P2, R> { - typedef R (Obj::*MemFun)(P1, P2); - - Ptr _ptr; - MemFun _mem_fun; - - virtual R call(P1 param1, P2 param2) override - { return ((*_ptr).*_mem_fun)(std::move(param1), std::move(param2)); } - -public: - MemberClosure2_0(Ptr ptr, MemFun mem_fun) - : _ptr(std::move(ptr)), _mem_fun(mem_fun) {} -}; - -/** Implementation of Closure2 binding one argument to a member function. */ -template <class Ptr, class Obj, typename T1, typename P1, typename P2, typename R> -class MemberClosure2_1 : public Closure2<P1, P2, R> { - typedef R (Obj::*MemFun)(T1, P1, P2); - - Ptr _ptr; - MemFun _mem_fun; - T1 _arg1; - - virtual R call(P1 param1, P2 param2) override - { return ((*_ptr).*_mem_fun)(std::move(_arg1), std::move(param1), std::move(param2)); } - -public: - MemberClosure2_1(Ptr ptr, MemFun mem_fun, T1 arg1) - : _ptr(std::move(ptr)), _mem_fun(mem_fun), _arg1(std::move(arg1)) {} -}; - -/** Implementation of Closure2 binding two arguments to a member function. */ -template <class Ptr, class Obj, typename T1, typename T2, typename P1, typename P2, typename R> -class MemberClosure2_2 : public Closure2<P1, P2, R> { - typedef R (Obj::*MemFun)(T1, T2, P1, P2); - - Ptr _ptr; - MemFun _mem_fun; - T1 _arg1; - T2 _arg2; - - virtual R call(P1 param1, P2 param2) override - { return ((*_ptr).*_mem_fun)(std::move(_arg1), std::move(_arg2), std::move(param1), std::move(param2)); } - -public: - MemberClosure2_2(Ptr ptr, MemFun mem_fun, T1 arg1, T2 arg2) - : _ptr(std::move(ptr)), _mem_fun(mem_fun), _arg1(std::move(arg1)), _arg2(std::move(arg2)) {} -}; - -/** Implementation of Closure2 binding three arguments to a member function. */ -template <class Ptr, class Obj, typename T1, typename T2, typename T3, typename P1, typename P2, typename R> -class MemberClosure2_3 : public Closure2<P1, P2, R> { - typedef R (Obj::*MemFun)(T1, T2, T3, P1, P2); - - Ptr _ptr; - MemFun _mem_fun; - T1 _arg1; - T2 _arg2; - T3 _arg3; - - virtual R call(P1 param1, P2 param2) override - { return ((*_ptr).*_mem_fun)(std::move(_arg1), std::move(_arg2), std::move(_arg3), std::move(param1), std::move(param2)); } - -public: - MemberClosure2_3(Ptr ptr, MemFun mem_fun, T1 arg1, T2 arg2, T3 arg3) - : _ptr(std::move(ptr)), _mem_fun(mem_fun), _arg1(std::move(arg1)), _arg2(std::move(arg2)), _arg3(std::move(arg3)) {} -}; - -/** Implementation of Closure2 binding four arguments to a member function. */ -template <class Ptr, class Obj, typename T1, typename T2, typename T3, typename T4, typename P1, typename P2, typename R> -class MemberClosure2_4 : public Closure2<P1, P2, R> { - typedef R (Obj::*MemFun)(T1, T2, T3, T4, P1, P2); - - Ptr _ptr; - MemFun _mem_fun; - T1 _arg1; - T2 _arg2; - T3 _arg3; - T4 _arg4; - - virtual R call(P1 param1, P2 param2) override - { return ((*_ptr).*_mem_fun)(std::move(_arg1), std::move(_arg2), std::move(_arg3), std::move(_arg4), std::move(param1), std::move(param2)); } - -public: - MemberClosure2_4(Ptr ptr, MemFun mem_fun, T1 arg1, T2 arg2, T3 arg3, T4 arg4) - : _ptr(std::move(ptr)), _mem_fun(mem_fun), _arg1(std::move(arg1)), _arg2(std::move(arg2)), _arg3(std::move(arg3)), _arg4(std::move(arg4)) {} -}; - -// Closure3 ------------------------------------------------------------------- - -/** Implementation of Closure3 binding no arguments to a free function. */ -template <typename P1, typename P2, typename P3, typename R> -class Closure3_0 : public Closure3<P1, P2, P3, R> { - typedef R (*Func)(P1, P2, P3); - - Func _func; - - virtual R call(P1 param1, P2 param2, P3 param3) override - { return _func(std::move(param1), std::move(param2), std::move(param3)); } - -public: - Closure3_0(Func func) - : _func(func) {} -}; - -/** Implementation of Closure3 binding one argument to a free function. */ -template <typename T1, typename P1, typename P2, typename P3, typename R> -class Closure3_1 : public Closure3<P1, P2, P3, R> { - typedef R (*Func)(T1, P1, P2, P3); - - Func _func; - T1 _arg1; - - virtual R call(P1 param1, P2 param2, P3 param3) override - { return _func(std::move(_arg1), std::move(param1), std::move(param2), std::move(param3)); } - -public: - Closure3_1(Func func, T1 &&arg1) - : _func(func), _arg1(std::move(arg1)) {} -}; - -/** Implementation of Closure3 binding two arguments to a free function. */ -template <typename T1, typename T2, typename P1, typename P2, typename P3, typename R> -class Closure3_2 : public Closure3<P1, P2, P3, R> { - typedef R (*Func)(T1, T2, P1, P2, P3); - - Func _func; - T1 _arg1; - T2 _arg2; - - virtual R call(P1 param1, P2 param2, P3 param3) override - { return _func(std::move(_arg1), std::move(_arg2), std::move(param1), std::move(param2), std::move(param3)); } - -public: - Closure3_2(Func func, T1 &&arg1, T2 &&arg2) - : _func(func), _arg1(std::move(arg1)), _arg2(std::move(arg2)) {} -}; - -/** Implementation of Closure3 binding three arguments to a free function. */ -template <typename T1, typename T2, typename T3, typename P1, typename P2, typename P3, typename R> -class Closure3_3 : public Closure3<P1, P2, P3, R> { - typedef R (*Func)(T1, T2, T3, P1, P2, P3); - - Func _func; - T1 _arg1; - T2 _arg2; - T3 _arg3; - - virtual R call(P1 param1, P2 param2, P3 param3) override - { return _func(std::move(_arg1), std::move(_arg2), std::move(_arg3), std::move(param1), std::move(param2), std::move(param3)); } - -public: - Closure3_3(Func func, T1 &&arg1, T2 &&arg2, T3 &&arg3) - : _func(func), _arg1(std::move(arg1)), _arg2(std::move(arg2)), _arg3(std::move(arg3)) {} -}; - -/** Implementation of Closure3 binding four arguments to a free function. */ -template <typename T1, typename T2, typename T3, typename T4, typename P1, typename P2, typename P3, typename R> -class Closure3_4 : public Closure3<P1, P2, P3, R> { - typedef R (*Func)(T1, T2, T3, T4, P1, P2, P3); - - Func _func; - T1 _arg1; - T2 _arg2; - T3 _arg3; - T4 _arg4; - - virtual R call(P1 param1, P2 param2, P3 param3) override - { return _func(std::move(_arg1), std::move(_arg2), std::move(_arg3), std::move(_arg4), std::move(param1), std::move(param2), std::move(param3)); } - -public: - Closure3_4(Func func, T1 &&arg1, T2 &&arg2, T3 &&arg3, T4 &&arg4) - : _func(func), _arg1(std::move(arg1)), _arg2(std::move(arg2)), _arg3(std::move(arg3)), _arg4(std::move(arg4)) {} -}; - -// MemberClosure3 ------------------------------------------------------------- - -/** Implementation of Closure3 binding no arguments to a member function. */ -template <class Ptr, class Obj, typename P1, typename P2, typename P3, typename R> -class MemberClosure3_0 : public Closure3<P1, P2, P3, R> { - typedef R (Obj::*MemFun)(P1, P2, P3); - - Ptr _ptr; - MemFun _mem_fun; - - virtual R call(P1 param1, P2 param2, P3 param3) override - { return ((*_ptr).*_mem_fun)(std::move(param1), std::move(param2), std::move(param3)); } - -public: - MemberClosure3_0(Ptr ptr, MemFun mem_fun) - : _ptr(std::move(ptr)), _mem_fun(mem_fun) {} -}; - -/** Implementation of Closure3 binding one argument to a member function. */ -template <class Ptr, class Obj, typename T1, typename P1, typename P2, typename P3, typename R> -class MemberClosure3_1 : public Closure3<P1, P2, P3, R> { - typedef R (Obj::*MemFun)(T1, P1, P2, P3); - - Ptr _ptr; - MemFun _mem_fun; - T1 _arg1; - - virtual R call(P1 param1, P2 param2, P3 param3) override - { return ((*_ptr).*_mem_fun)(std::move(_arg1), std::move(param1), std::move(param2), std::move(param3)); } - -public: - MemberClosure3_1(Ptr ptr, MemFun mem_fun, T1 arg1) - : _ptr(std::move(ptr)), _mem_fun(mem_fun), _arg1(std::move(arg1)) {} -}; - -/** Implementation of Closure3 binding two arguments to a member function. */ -template <class Ptr, class Obj, typename T1, typename T2, typename P1, typename P2, typename P3, typename R> -class MemberClosure3_2 : public Closure3<P1, P2, P3, R> { - typedef R (Obj::*MemFun)(T1, T2, P1, P2, P3); - - Ptr _ptr; - MemFun _mem_fun; - T1 _arg1; - T2 _arg2; - - virtual R call(P1 param1, P2 param2, P3 param3) override - { return ((*_ptr).*_mem_fun)(std::move(_arg1), std::move(_arg2), std::move(param1), std::move(param2), std::move(param3)); } - -public: - MemberClosure3_2(Ptr ptr, MemFun mem_fun, T1 arg1, T2 arg2) - : _ptr(std::move(ptr)), _mem_fun(mem_fun), _arg1(std::move(arg1)), _arg2(std::move(arg2)) {} -}; - -/** Implementation of Closure3 binding three arguments to a member function. */ -template <class Ptr, class Obj, typename T1, typename T2, typename T3, typename P1, typename P2, typename P3, typename R> -class MemberClosure3_3 : public Closure3<P1, P2, P3, R> { - typedef R (Obj::*MemFun)(T1, T2, T3, P1, P2, P3); - - Ptr _ptr; - MemFun _mem_fun; - T1 _arg1; - T2 _arg2; - T3 _arg3; - - virtual R call(P1 param1, P2 param2, P3 param3) override - { return ((*_ptr).*_mem_fun)(std::move(_arg1), std::move(_arg2), std::move(_arg3), std::move(param1), std::move(param2), std::move(param3)); } - -public: - MemberClosure3_3(Ptr ptr, MemFun mem_fun, T1 arg1, T2 arg2, T3 arg3) - : _ptr(std::move(ptr)), _mem_fun(mem_fun), _arg1(std::move(arg1)), _arg2(std::move(arg2)), _arg3(std::move(arg3)) {} -}; - -/** Implementation of Closure3 binding four arguments to a member function. */ -template <class Ptr, class Obj, typename T1, typename T2, typename T3, typename T4, typename P1, typename P2, typename P3, typename R> -class MemberClosure3_4 : public Closure3<P1, P2, P3, R> { - typedef R (Obj::*MemFun)(T1, T2, T3, T4, P1, P2, P3); - - Ptr _ptr; - MemFun _mem_fun; - T1 _arg1; - T2 _arg2; - T3 _arg3; - T4 _arg4; - - virtual R call(P1 param1, P2 param2, P3 param3) override - { return ((*_ptr).*_mem_fun)(std::move(_arg1), std::move(_arg2), std::move(_arg3), std::move(_arg4), std::move(param1), std::move(param2), std::move(param3)); } - -public: - MemberClosure3_4(Ptr ptr, MemFun mem_fun, T1 arg1, T2 arg2, T3 arg3, T4 arg4) - : _ptr(std::move(ptr)), _mem_fun(mem_fun), _arg1(std::move(arg1)), _arg2(std::move(arg2)), _arg3(std::move(arg3)), _arg4(std::move(arg4)) {} -}; - -// Closure4 ------------------------------------------------------------------- - -/** Implementation of Closure4 binding no arguments to a free function. */ -template <typename P1, typename P2, typename P3, typename P4, typename R> -class Closure4_0 : public Closure4<P1, P2, P3, P4, R> { - typedef R (*Func)(P1, P2, P3, P4); - - Func _func; - - virtual R call(P1 param1, P2 param2, P3 param3, P4 param4) override - { return _func(std::move(param1), std::move(param2), std::move(param3), std::move(param4)); } - -public: - Closure4_0(Func func) - : _func(func) {} -}; - -/** Implementation of Closure4 binding one argument to a free function. */ -template <typename T1, typename P1, typename P2, typename P3, typename P4, typename R> -class Closure4_1 : public Closure4<P1, P2, P3, P4, R> { - typedef R (*Func)(T1, P1, P2, P3, P4); - - Func _func; - T1 _arg1; - - virtual R call(P1 param1, P2 param2, P3 param3, P4 param4) override - { return _func(std::move(_arg1), std::move(param1), std::move(param2), std::move(param3), std::move(param4)); } - -public: - Closure4_1(Func func, T1 &&arg1) - : _func(func), _arg1(std::move(arg1)) {} -}; - -/** Implementation of Closure4 binding two arguments to a free function. */ -template <typename T1, typename T2, typename P1, typename P2, typename P3, typename P4, typename R> -class Closure4_2 : public Closure4<P1, P2, P3, P4, R> { - typedef R (*Func)(T1, T2, P1, P2, P3, P4); - - Func _func; - T1 _arg1; - T2 _arg2; - - virtual R call(P1 param1, P2 param2, P3 param3, P4 param4) override - { return _func(std::move(_arg1), std::move(_arg2), std::move(param1), std::move(param2), std::move(param3), std::move(param4)); } - -public: - Closure4_2(Func func, T1 &&arg1, T2 &&arg2) - : _func(func), _arg1(std::move(arg1)), _arg2(std::move(arg2)) {} -}; - -/** Implementation of Closure4 binding three arguments to a free function. */ -template <typename T1, typename T2, typename T3, typename P1, typename P2, typename P3, typename P4, typename R> -class Closure4_3 : public Closure4<P1, P2, P3, P4, R> { - typedef R (*Func)(T1, T2, T3, P1, P2, P3, P4); - - Func _func; - T1 _arg1; - T2 _arg2; - T3 _arg3; - - virtual R call(P1 param1, P2 param2, P3 param3, P4 param4) override - { return _func(std::move(_arg1), std::move(_arg2), std::move(_arg3), std::move(param1), std::move(param2), std::move(param3), std::move(param4)); } - -public: - Closure4_3(Func func, T1 &&arg1, T2 &&arg2, T3 &&arg3) - : _func(func), _arg1(std::move(arg1)), _arg2(std::move(arg2)), _arg3(std::move(arg3)) {} -}; - -/** Implementation of Closure4 binding four arguments to a free function. */ -template <typename T1, typename T2, typename T3, typename T4, typename P1, typename P2, typename P3, typename P4, typename R> -class Closure4_4 : public Closure4<P1, P2, P3, P4, R> { - typedef R (*Func)(T1, T2, T3, T4, P1, P2, P3, P4); - - Func _func; - T1 _arg1; - T2 _arg2; - T3 _arg3; - T4 _arg4; - - virtual R call(P1 param1, P2 param2, P3 param3, P4 param4) override - { return _func(std::move(_arg1), std::move(_arg2), std::move(_arg3), std::move(_arg4), std::move(param1), std::move(param2), std::move(param3), std::move(param4)); } - -public: - Closure4_4(Func func, T1 &&arg1, T2 &&arg2, T3 &&arg3, T4 &&arg4) - : _func(func), _arg1(std::move(arg1)), _arg2(std::move(arg2)), _arg3(std::move(arg3)), _arg4(std::move(arg4)) {} -}; - -// MemberClosure4 ------------------------------------------------------------- - -/** Implementation of Closure4 binding no arguments to a member function. */ -template <class Ptr, class Obj, typename P1, typename P2, typename P3, typename P4, typename R> -class MemberClosure4_0 : public Closure4<P1, P2, P3, P4, R> { - typedef R (Obj::*MemFun)(P1, P2, P3, P4); - - Ptr _ptr; - MemFun _mem_fun; - - virtual R call(P1 param1, P2 param2, P3 param3, P4 param4) override - { return ((*_ptr).*_mem_fun)(std::move(param1), std::move(param2), std::move(param3), std::move(param4)); } - -public: - MemberClosure4_0(Ptr ptr, MemFun mem_fun) - : _ptr(std::move(ptr)), _mem_fun(mem_fun) {} -}; - -/** Implementation of Closure4 binding one argument to a member function. */ -template <class Ptr, class Obj, typename T1, typename P1, typename P2, typename P3, typename P4, typename R> -class MemberClosure4_1 : public Closure4<P1, P2, P3, P4, R> { - typedef R (Obj::*MemFun)(T1, P1, P2, P3, P4); - - Ptr _ptr; - MemFun _mem_fun; - T1 _arg1; - - virtual R call(P1 param1, P2 param2, P3 param3, P4 param4) override - { return ((*_ptr).*_mem_fun)(std::move(_arg1), std::move(param1), std::move(param2), std::move(param3), std::move(param4)); } - -public: - MemberClosure4_1(Ptr ptr, MemFun mem_fun, T1 arg1) - : _ptr(std::move(ptr)), _mem_fun(mem_fun), _arg1(std::move(arg1)) {} -}; - -/** Implementation of Closure4 binding two arguments to a member function. */ -template <class Ptr, class Obj, typename T1, typename T2, typename P1, typename P2, typename P3, typename P4, typename R> -class MemberClosure4_2 : public Closure4<P1, P2, P3, P4, R> { - typedef R (Obj::*MemFun)(T1, T2, P1, P2, P3, P4); - - Ptr _ptr; - MemFun _mem_fun; - T1 _arg1; - T2 _arg2; - - virtual R call(P1 param1, P2 param2, P3 param3, P4 param4) override - { return ((*_ptr).*_mem_fun)(std::move(_arg1), std::move(_arg2), std::move(param1), std::move(param2), std::move(param3), std::move(param4)); } - -public: - MemberClosure4_2(Ptr ptr, MemFun mem_fun, T1 arg1, T2 arg2) - : _ptr(std::move(ptr)), _mem_fun(mem_fun), _arg1(std::move(arg1)), _arg2(std::move(arg2)) {} -}; - -/** Implementation of Closure4 binding three arguments to a member function. */ -template <class Ptr, class Obj, typename T1, typename T2, typename T3, typename P1, typename P2, typename P3, typename P4, typename R> -class MemberClosure4_3 : public Closure4<P1, P2, P3, P4, R> { - typedef R (Obj::*MemFun)(T1, T2, T3, P1, P2, P3, P4); - - Ptr _ptr; - MemFun _mem_fun; - T1 _arg1; - T2 _arg2; - T3 _arg3; - - virtual R call(P1 param1, P2 param2, P3 param3, P4 param4) override - { return ((*_ptr).*_mem_fun)(std::move(_arg1), std::move(_arg2), std::move(_arg3), std::move(param1), std::move(param2), std::move(param3), std::move(param4)); } - -public: - MemberClosure4_3(Ptr ptr, MemFun mem_fun, T1 arg1, T2 arg2, T3 arg3) - : _ptr(std::move(ptr)), _mem_fun(mem_fun), _arg1(std::move(arg1)), _arg2(std::move(arg2)), _arg3(std::move(arg3)) {} -}; - -/** Implementation of Closure4 binding four arguments to a member function. */ -template <class Ptr, class Obj, typename T1, typename T2, typename T3, typename T4, typename P1, typename P2, typename P3, typename P4, typename R> -class MemberClosure4_4 : public Closure4<P1, P2, P3, P4, R> { - typedef R (Obj::*MemFun)(T1, T2, T3, T4, P1, P2, P3, P4); - - Ptr _ptr; - MemFun _mem_fun; - T1 _arg1; - T2 _arg2; - T3 _arg3; - T4 _arg4; - - virtual R call(P1 param1, P2 param2, P3 param3, P4 param4) override - { return ((*_ptr).*_mem_fun)(std::move(_arg1), std::move(_arg2), std::move(_arg3), std::move(_arg4), std::move(param1), std::move(param2), std::move(param3), std::move(param4)); } - -public: - MemberClosure4_4(Ptr ptr, MemFun mem_fun, T1 arg1, T2 arg2, T3 arg3, T4 arg4) - : _ptr(std::move(ptr)), _mem_fun(mem_fun), _arg1(std::move(arg1)), _arg2(std::move(arg2)), _arg3(std::move(arg3)), _arg4(std::move(arg4)) {} -}; - -// Function closures (0) ------------------------------------------------------ - -/** Creates a Closure0 from a free function, binding no arguments. */ -template <typename R> -std::unique_ptr<Closure0<R> > -makeClosure(R (*func)()) { - return std::unique_ptr<Closure0<R> >( - new Closure0_0<R>(func)); -} - -/** Creates a Closure0 from a free function, binding one argument. */ -template <typename T1, typename R> -std::unique_ptr<Closure0<R> > -makeClosure(R (*func)(T1), T1 arg1) { - return std::unique_ptr<Closure0<R> >( - new Closure0_1<T1, R>(func, std::move(arg1))); -} - -/** Creates a Closure0 from a free function, binding two arguments. */ -template <typename T1, typename T2, typename R> -std::unique_ptr<Closure0<R> > -makeClosure(R (*func)(T1, T2), T1 arg1, T2 arg2) { - return std::unique_ptr<Closure0<R> >( - new Closure0_2<T1, T2, R>(func, std::move(arg1), std::move(arg2))); -} - -/** Creates a Closure0 from a free function, binding three arguments. */ -template <typename T1, typename T2, typename T3, typename R> -std::unique_ptr<Closure0<R> > -makeClosure(R (*func)(T1, T2, T3), T1 arg1, T2 arg2, T3 arg3) { - return std::unique_ptr<Closure0<R> >( - new Closure0_3<T1, T2, T3, R>(func, std::move(arg1), std::move(arg2), std::move(arg3))); -} - -/** Creates a Closure0 from a free function, binding four arguments. */ -template <typename T1, typename T2, typename T3, typename T4, typename R> -std::unique_ptr<Closure0<R> > -makeClosure(R (*func)(T1, T2, T3, T4), T1 arg1, T2 arg2, T3 arg3, T4 arg4) { - return std::unique_ptr<Closure0<R> >( - new Closure0_4<T1, T2, T3, T4, R>(func, std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4))); -} - -// Member closures (0) -------------------------------------------------------- - -/** Creates a Closure0 from a member function, binding no arguments. */ -template <class Ptr, class Obj, typename R> -std::unique_ptr<Closure0<R> > -makeClosure(Ptr ptr, R (Obj::*mem_fun)()) { - return std::unique_ptr<Closure0<R> >( - new MemberClosure0_0<Ptr, Obj, R>( - std::move(ptr), mem_fun)); -} - -/** Creates a Closure0 from a member function, binding one argument. */ -template <class Ptr, class Obj, typename T1, typename R> -std::unique_ptr<Closure0<R> > -makeClosure(Ptr ptr, R (Obj::*mem_fun)(T1), T1 arg1) { - return std::unique_ptr<Closure0<R> >( - new MemberClosure0_1<Ptr, Obj, T1, R>( - std::move(ptr), mem_fun, std::move(arg1))); -} - -/** Creates a Closure0 from a member function, binding two arguments. */ -template <class Ptr, class Obj, typename T1, typename T2, typename R> -std::unique_ptr<Closure0<R> > -makeClosure(Ptr ptr, R (Obj::*mem_fun)(T1, T2), T1 arg1, T2 arg2) { - return std::unique_ptr<Closure0<R> >( - new MemberClosure0_2<Ptr, Obj, T1, T2, R>( - std::move(ptr), mem_fun, std::move(arg1), std::move(arg2))); -} - -/** Creates a Closure0 from a member function, binding three arguments. */ -template <class Ptr, class Obj, typename T1, typename T2, typename T3, typename R> -std::unique_ptr<Closure0<R> > -makeClosure(Ptr ptr, R (Obj::*mem_fun)(T1, T2, T3), T1 arg1, T2 arg2, T3 arg3) { - return std::unique_ptr<Closure0<R> >( - new MemberClosure0_3<Ptr, Obj, T1, T2, T3, R>( - std::move(ptr), mem_fun, std::move(arg1), std::move(arg2), std::move(arg3))); -} - -/** Creates a Closure0 from a member function, binding four arguments. */ -template <class Ptr, class Obj, typename T1, typename T2, typename T3, typename T4, typename R> -std::unique_ptr<Closure0<R> > -makeClosure(Ptr ptr, R (Obj::*mem_fun)(T1, T2, T3, T4), T1 arg1, T2 arg2, T3 arg3, T4 arg4) { - return std::unique_ptr<Closure0<R> >( - new MemberClosure0_4<Ptr, Obj, T1, T2, T3, T4, R>( - std::move(ptr), mem_fun, std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4))); -} - -// Function closures (1) ------------------------------------------------------ - -/** Creates a Closure1 from a free function, binding no arguments. */ -template <typename P1, typename R> -std::unique_ptr<Closure1<P1, R> > -makeClosure(R (*func)(P1)) { - return std::unique_ptr<Closure1<P1, R> >( - new Closure1_0<P1, R>(func)); -} - -/** Creates a Closure1 from a free function, binding one argument. */ -template <typename T1, typename P1, typename R> -std::unique_ptr<Closure1<P1, R> > -makeClosure(R (*func)(T1, P1), T1 arg1) { - return std::unique_ptr<Closure1<P1, R> >( - new Closure1_1<T1, P1, R>(func, std::move(arg1))); -} - -/** Creates a Closure1 from a free function, binding two arguments. */ -template <typename T1, typename T2, typename P1, typename R> -std::unique_ptr<Closure1<P1, R> > -makeClosure(R (*func)(T1, T2, P1), T1 arg1, T2 arg2) { - return std::unique_ptr<Closure1<P1, R> >( - new Closure1_2<T1, T2, P1, R>(func, std::move(arg1), std::move(arg2))); -} - -/** Creates a Closure1 from a free function, binding three arguments. */ -template <typename T1, typename T2, typename T3, typename P1, typename R> -std::unique_ptr<Closure1<P1, R> > -makeClosure(R (*func)(T1, T2, T3, P1), T1 arg1, T2 arg2, T3 arg3) { - return std::unique_ptr<Closure1<P1, R> >( - new Closure1_3<T1, T2, T3, P1, R>(func, std::move(arg1), std::move(arg2), std::move(arg3))); -} - -/** Creates a Closure1 from a free function, binding four arguments. */ -template <typename T1, typename T2, typename T3, typename T4, typename P1, typename R> -std::unique_ptr<Closure1<P1, R> > -makeClosure(R (*func)(T1, T2, T3, T4, P1), T1 arg1, T2 arg2, T3 arg3, T4 arg4) { - return std::unique_ptr<Closure1<P1, R> >( - new Closure1_4<T1, T2, T3, T4, P1, R>(func, std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4))); -} - -// Member closures (1) -------------------------------------------------------- - -/** Creates a Closure1 from a member function, binding no arguments. */ -template <class Ptr, class Obj, typename P1, typename R> -std::unique_ptr<Closure1<P1, R> > -makeClosure(Ptr ptr, R (Obj::*mem_fun)(P1)) { - return std::unique_ptr<Closure1<P1, R> >( - new MemberClosure1_0<Ptr, Obj, P1, R>( - std::move(ptr), mem_fun)); -} - -/** Creates a Closure1 from a member function, binding one argument. */ -template <class Ptr, class Obj, typename T1, typename P1, typename R> -std::unique_ptr<Closure1<P1, R> > -makeClosure(Ptr ptr, R (Obj::*mem_fun)(T1, P1), T1 arg1) { - return std::unique_ptr<Closure1<P1, R> >( - new MemberClosure1_1<Ptr, Obj, T1, P1, R>( - std::move(ptr), mem_fun, std::move(arg1))); -} - -/** Creates a Closure1 from a member function, binding two arguments. */ -template <class Ptr, class Obj, typename T1, typename T2, typename P1, typename R> -std::unique_ptr<Closure1<P1, R> > -makeClosure(Ptr ptr, R (Obj::*mem_fun)(T1, T2, P1), T1 arg1, T2 arg2) { - return std::unique_ptr<Closure1<P1, R> >( - new MemberClosure1_2<Ptr, Obj, T1, T2, P1, R>( - std::move(ptr), mem_fun, std::move(arg1), std::move(arg2))); -} - -/** Creates a Closure1 from a member function, binding three arguments. */ -template <class Ptr, class Obj, typename T1, typename T2, typename T3, typename P1, typename R> -std::unique_ptr<Closure1<P1, R> > -makeClosure(Ptr ptr, R (Obj::*mem_fun)(T1, T2, T3, P1), T1 arg1, T2 arg2, T3 arg3) { - return std::unique_ptr<Closure1<P1, R> >( - new MemberClosure1_3<Ptr, Obj, T1, T2, T3, P1, R>( - std::move(ptr), mem_fun, std::move(arg1), std::move(arg2), std::move(arg3))); -} - -/** Creates a Closure1 from a member function, binding four arguments. */ -template <class Ptr, class Obj, typename T1, typename T2, typename T3, typename T4, typename P1, typename R> -std::unique_ptr<Closure1<P1, R> > -makeClosure(Ptr ptr, R (Obj::*mem_fun)(T1, T2, T3, T4, P1), T1 arg1, T2 arg2, T3 arg3, T4 arg4) { - return std::unique_ptr<Closure1<P1, R> >( - new MemberClosure1_4<Ptr, Obj, T1, T2, T3, T4, P1, R>( - std::move(ptr), mem_fun, std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4))); -} - -// Function closures (2) ------------------------------------------------------ - -/** Creates a Closure2 from a free function, binding no arguments. */ -template <typename P1, typename P2, typename R> -std::unique_ptr<Closure2<P1, P2, R> > -makeClosure(R (*func)(P1, P2)) { - return std::unique_ptr<Closure2<P1, P2, R> >( - new Closure2_0<P1, P2, R>(func)); -} - -/** Creates a Closure2 from a free function, binding one argument. */ -template <typename T1, typename P1, typename P2, typename R> -std::unique_ptr<Closure2<P1, P2, R> > -makeClosure(R (*func)(T1, P1, P2), T1 arg1) { - return std::unique_ptr<Closure2<P1, P2, R> >( - new Closure2_1<T1, P1, P2, R>(func, std::move(arg1))); -} - -/** Creates a Closure2 from a free function, binding two arguments. */ -template <typename T1, typename T2, typename P1, typename P2, typename R> -std::unique_ptr<Closure2<P1, P2, R> > -makeClosure(R (*func)(T1, T2, P1, P2), T1 arg1, T2 arg2) { - return std::unique_ptr<Closure2<P1, P2, R> >( - new Closure2_2<T1, T2, P1, P2, R>(func, std::move(arg1), std::move(arg2))); -} - -/** Creates a Closure2 from a free function, binding three arguments. */ -template <typename T1, typename T2, typename T3, typename P1, typename P2, typename R> -std::unique_ptr<Closure2<P1, P2, R> > -makeClosure(R (*func)(T1, T2, T3, P1, P2), T1 arg1, T2 arg2, T3 arg3) { - return std::unique_ptr<Closure2<P1, P2, R> >( - new Closure2_3<T1, T2, T3, P1, P2, R>(func, std::move(arg1), std::move(arg2), std::move(arg3))); -} - -/** Creates a Closure2 from a free function, binding four arguments. */ -template <typename T1, typename T2, typename T3, typename T4, typename P1, typename P2, typename R> -std::unique_ptr<Closure2<P1, P2, R> > -makeClosure(R (*func)(T1, T2, T3, T4, P1, P2), T1 arg1, T2 arg2, T3 arg3, T4 arg4) { - return std::unique_ptr<Closure2<P1, P2, R> >( - new Closure2_4<T1, T2, T3, T4, P1, P2, R>(func, std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4))); -} - -// Member closures (2) -------------------------------------------------------- - -/** Creates a Closure2 from a member function, binding no arguments. */ -template <class Ptr, class Obj, typename P1, typename P2, typename R> -std::unique_ptr<Closure2<P1, P2, R> > -makeClosure(Ptr ptr, R (Obj::*mem_fun)(P1, P2)) { - return std::unique_ptr<Closure2<P1, P2, R> >( - new MemberClosure2_0<Ptr, Obj, P1, P2, R>( - std::move(ptr), mem_fun)); -} - -/** Creates a Closure2 from a member function, binding one argument. */ -template <class Ptr, class Obj, typename T1, typename P1, typename P2, typename R> -std::unique_ptr<Closure2<P1, P2, R> > -makeClosure(Ptr ptr, R (Obj::*mem_fun)(T1, P1, P2), T1 arg1) { - return std::unique_ptr<Closure2<P1, P2, R> >( - new MemberClosure2_1<Ptr, Obj, T1, P1, P2, R>( - std::move(ptr), mem_fun, std::move(arg1))); -} - -/** Creates a Closure2 from a member function, binding two arguments. */ -template <class Ptr, class Obj, typename T1, typename T2, typename P1, typename P2, typename R> -std::unique_ptr<Closure2<P1, P2, R> > -makeClosure(Ptr ptr, R (Obj::*mem_fun)(T1, T2, P1, P2), T1 arg1, T2 arg2) { - return std::unique_ptr<Closure2<P1, P2, R> >( - new MemberClosure2_2<Ptr, Obj, T1, T2, P1, P2, R>( - std::move(ptr), mem_fun, std::move(arg1), std::move(arg2))); -} - -/** Creates a Closure2 from a member function, binding three arguments. */ -template <class Ptr, class Obj, typename T1, typename T2, typename T3, typename P1, typename P2, typename R> -std::unique_ptr<Closure2<P1, P2, R> > -makeClosure(Ptr ptr, R (Obj::*mem_fun)(T1, T2, T3, P1, P2), T1 arg1, T2 arg2, T3 arg3) { - return std::unique_ptr<Closure2<P1, P2, R> >( - new MemberClosure2_3<Ptr, Obj, T1, T2, T3, P1, P2, R>( - std::move(ptr), mem_fun, std::move(arg1), std::move(arg2), std::move(arg3))); -} - -/** Creates a Closure2 from a member function, binding four arguments. */ -template <class Ptr, class Obj, typename T1, typename T2, typename T3, typename T4, typename P1, typename P2, typename R> -std::unique_ptr<Closure2<P1, P2, R> > -makeClosure(Ptr ptr, R (Obj::*mem_fun)(T1, T2, T3, T4, P1, P2), T1 arg1, T2 arg2, T3 arg3, T4 arg4) { - return std::unique_ptr<Closure2<P1, P2, R> >( - new MemberClosure2_4<Ptr, Obj, T1, T2, T3, T4, P1, P2, R>( - std::move(ptr), mem_fun, std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4))); -} - -// Function closures (3) ------------------------------------------------------ - -/** Creates a Closure3 from a free function, binding no arguments. */ -template <typename P1, typename P2, typename P3, typename R> -std::unique_ptr<Closure3<P1, P2, P3, R> > -makeClosure(R (*func)(P1, P2, P3)) { - return std::unique_ptr<Closure3<P1, P2, P3, R> >( - new Closure3_0<P1, P2, P3, R>(func)); -} - -/** Creates a Closure3 from a free function, binding one argument. */ -template <typename T1, typename P1, typename P2, typename P3, typename R> -std::unique_ptr<Closure3<P1, P2, P3, R> > -makeClosure(R (*func)(T1, P1, P2, P3), T1 arg1) { - return std::unique_ptr<Closure3<P1, P2, P3, R> >( - new Closure3_1<T1, P1, P2, P3, R>(func, std::move(arg1))); -} - -/** Creates a Closure3 from a free function, binding two arguments. */ -template <typename T1, typename T2, typename P1, typename P2, typename P3, typename R> -std::unique_ptr<Closure3<P1, P2, P3, R> > -makeClosure(R (*func)(T1, T2, P1, P2, P3), T1 arg1, T2 arg2) { - return std::unique_ptr<Closure3<P1, P2, P3, R> >( - new Closure3_2<T1, T2, P1, P2, P3, R>(func, std::move(arg1), std::move(arg2))); -} - -/** Creates a Closure3 from a free function, binding three arguments. */ -template <typename T1, typename T2, typename T3, typename P1, typename P2, typename P3, typename R> -std::unique_ptr<Closure3<P1, P2, P3, R> > -makeClosure(R (*func)(T1, T2, T3, P1, P2, P3), T1 arg1, T2 arg2, T3 arg3) { - return std::unique_ptr<Closure3<P1, P2, P3, R> >( - new Closure3_3<T1, T2, T3, P1, P2, P3, R>(func, std::move(arg1), std::move(arg2), std::move(arg3))); -} - -/** Creates a Closure3 from a free function, binding four arguments. */ -template <typename T1, typename T2, typename T3, typename T4, typename P1, typename P2, typename P3, typename R> -std::unique_ptr<Closure3<P1, P2, P3, R> > -makeClosure(R (*func)(T1, T2, T3, T4, P1, P2, P3), T1 arg1, T2 arg2, T3 arg3, T4 arg4) { - return std::unique_ptr<Closure3<P1, P2, P3, R> >( - new Closure3_4<T1, T2, T3, T4, P1, P2, P3, R>(func, std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4))); -} - -// Member closures (3) -------------------------------------------------------- - -/** Creates a Closure3 from a member function, binding no arguments. */ -template <class Ptr, class Obj, typename P1, typename P2, typename P3, typename R> -std::unique_ptr<Closure3<P1, P2, P3, R> > -makeClosure(Ptr ptr, R (Obj::*mem_fun)(P1, P2, P3)) { - return std::unique_ptr<Closure3<P1, P2, P3, R> >( - new MemberClosure3_0<Ptr, Obj, P1, P2, P3, R>( - std::move(ptr), mem_fun)); -} - -/** Creates a Closure3 from a member function, binding one argument. */ -template <class Ptr, class Obj, typename T1, typename P1, typename P2, typename P3, typename R> -std::unique_ptr<Closure3<P1, P2, P3, R> > -makeClosure(Ptr ptr, R (Obj::*mem_fun)(T1, P1, P2, P3), T1 arg1) { - return std::unique_ptr<Closure3<P1, P2, P3, R> >( - new MemberClosure3_1<Ptr, Obj, T1, P1, P2, P3, R>( - std::move(ptr), mem_fun, std::move(arg1))); -} - -/** Creates a Closure3 from a member function, binding two arguments. */ -template <class Ptr, class Obj, typename T1, typename T2, typename P1, typename P2, typename P3, typename R> -std::unique_ptr<Closure3<P1, P2, P3, R> > -makeClosure(Ptr ptr, R (Obj::*mem_fun)(T1, T2, P1, P2, P3), T1 arg1, T2 arg2) { - return std::unique_ptr<Closure3<P1, P2, P3, R> >( - new MemberClosure3_2<Ptr, Obj, T1, T2, P1, P2, P3, R>( - std::move(ptr), mem_fun, std::move(arg1), std::move(arg2))); -} - -/** Creates a Closure3 from a member function, binding three arguments. */ -template <class Ptr, class Obj, typename T1, typename T2, typename T3, typename P1, typename P2, typename P3, typename R> -std::unique_ptr<Closure3<P1, P2, P3, R> > -makeClosure(Ptr ptr, R (Obj::*mem_fun)(T1, T2, T3, P1, P2, P3), T1 arg1, T2 arg2, T3 arg3) { - return std::unique_ptr<Closure3<P1, P2, P3, R> >( - new MemberClosure3_3<Ptr, Obj, T1, T2, T3, P1, P2, P3, R>( - std::move(ptr), mem_fun, std::move(arg1), std::move(arg2), std::move(arg3))); -} - -/** Creates a Closure3 from a member function, binding four arguments. */ -template <class Ptr, class Obj, typename T1, typename T2, typename T3, typename T4, typename P1, typename P2, typename P3, typename R> -std::unique_ptr<Closure3<P1, P2, P3, R> > -makeClosure(Ptr ptr, R (Obj::*mem_fun)(T1, T2, T3, T4, P1, P2, P3), T1 arg1, T2 arg2, T3 arg3, T4 arg4) { - return std::unique_ptr<Closure3<P1, P2, P3, R> >( - new MemberClosure3_4<Ptr, Obj, T1, T2, T3, T4, P1, P2, P3, R>( - std::move(ptr), mem_fun, std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4))); -} - -// Function closures (4) ------------------------------------------------------ - -/** Creates a Closure4 from a free function, binding no arguments. */ -template <typename P1, typename P2, typename P3, typename P4, typename R> -std::unique_ptr<Closure4<P1, P2, P3, P4, R> > -makeClosure(R (*func)(P1, P2, P3, P4)) { - return std::unique_ptr<Closure4<P1, P2, P3, P4, R> >( - new Closure4_0<P1, P2, P3, P4, R>(func)); -} - -/** Creates a Closure4 from a free function, binding one argument. */ -template <typename T1, typename P1, typename P2, typename P3, typename P4, typename R> -std::unique_ptr<Closure4<P1, P2, P3, P4, R> > -makeClosure(R (*func)(T1, P1, P2, P3, P4), T1 arg1) { - return std::unique_ptr<Closure4<P1, P2, P3, P4, R> >( - new Closure4_1<T1, P1, P2, P3, P4, R>(func, std::move(arg1))); -} - -/** Creates a Closure4 from a free function, binding two arguments. */ -template <typename T1, typename T2, typename P1, typename P2, typename P3, typename P4, typename R> -std::unique_ptr<Closure4<P1, P2, P3, P4, R> > -makeClosure(R (*func)(T1, T2, P1, P2, P3, P4), T1 arg1, T2 arg2) { - return std::unique_ptr<Closure4<P1, P2, P3, P4, R> >( - new Closure4_2<T1, T2, P1, P2, P3, P4, R>(func, std::move(arg1), std::move(arg2))); -} - -/** Creates a Closure4 from a free function, binding three arguments. */ -template <typename T1, typename T2, typename T3, typename P1, typename P2, typename P3, typename P4, typename R> -std::unique_ptr<Closure4<P1, P2, P3, P4, R> > -makeClosure(R (*func)(T1, T2, T3, P1, P2, P3, P4), T1 arg1, T2 arg2, T3 arg3) { - return std::unique_ptr<Closure4<P1, P2, P3, P4, R> >( - new Closure4_3<T1, T2, T3, P1, P2, P3, P4, R>(func, std::move(arg1), std::move(arg2), std::move(arg3))); -} - -/** Creates a Closure4 from a free function, binding four arguments. */ -template <typename T1, typename T2, typename T3, typename T4, typename P1, typename P2, typename P3, typename P4, typename R> -std::unique_ptr<Closure4<P1, P2, P3, P4, R> > -makeClosure(R (*func)(T1, T2, T3, T4, P1, P2, P3, P4), T1 arg1, T2 arg2, T3 arg3, T4 arg4) { - return std::unique_ptr<Closure4<P1, P2, P3, P4, R> >( - new Closure4_4<T1, T2, T3, T4, P1, P2, P3, P4, R>(func, std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4))); -} - -// Member closures (4) -------------------------------------------------------- - -/** Creates a Closure4 from a member function, binding no arguments. */ -template <class Ptr, class Obj, typename P1, typename P2, typename P3, typename P4, typename R> -std::unique_ptr<Closure4<P1, P2, P3, P4, R> > -makeClosure(Ptr ptr, R (Obj::*mem_fun)(P1, P2, P3, P4)) { - return std::unique_ptr<Closure4<P1, P2, P3, P4, R> >( - new MemberClosure4_0<Ptr, Obj, P1, P2, P3, P4, R>( - std::move(ptr), mem_fun)); -} - -/** Creates a Closure4 from a member function, binding one argument. */ -template <class Ptr, class Obj, typename T1, typename P1, typename P2, typename P3, typename P4, typename R> -std::unique_ptr<Closure4<P1, P2, P3, P4, R> > -makeClosure(Ptr ptr, R (Obj::*mem_fun)(T1, P1, P2, P3, P4), T1 arg1) { - return std::unique_ptr<Closure4<P1, P2, P3, P4, R> >( - new MemberClosure4_1<Ptr, Obj, T1, P1, P2, P3, P4, R>( - std::move(ptr), mem_fun, std::move(arg1))); -} - -/** Creates a Closure4 from a member function, binding two arguments. */ -template <class Ptr, class Obj, typename T1, typename T2, typename P1, typename P2, typename P3, typename P4, typename R> -std::unique_ptr<Closure4<P1, P2, P3, P4, R> > -makeClosure(Ptr ptr, R (Obj::*mem_fun)(T1, T2, P1, P2, P3, P4), T1 arg1, T2 arg2) { - return std::unique_ptr<Closure4<P1, P2, P3, P4, R> >( - new MemberClosure4_2<Ptr, Obj, T1, T2, P1, P2, P3, P4, R>( - std::move(ptr), mem_fun, std::move(arg1), std::move(arg2))); -} - -/** Creates a Closure4 from a member function, binding three arguments. */ -template <class Ptr, class Obj, typename T1, typename T2, typename T3, typename P1, typename P2, typename P3, typename P4, typename R> -std::unique_ptr<Closure4<P1, P2, P3, P4, R> > -makeClosure(Ptr ptr, R (Obj::*mem_fun)(T1, T2, T3, P1, P2, P3, P4), T1 arg1, T2 arg2, T3 arg3) { - return std::unique_ptr<Closure4<P1, P2, P3, P4, R> >( - new MemberClosure4_3<Ptr, Obj, T1, T2, T3, P1, P2, P3, P4, R>( - std::move(ptr), mem_fun, std::move(arg1), std::move(arg2), std::move(arg3))); -} - -/** Creates a Closure4 from a member function, binding four arguments. */ -template <class Ptr, class Obj, typename T1, typename T2, typename T3, typename T4, typename P1, typename P2, typename P3, typename P4, typename R> -std::unique_ptr<Closure4<P1, P2, P3, P4, R> > -makeClosure(Ptr ptr, R (Obj::*mem_fun)(T1, T2, T3, T4, P1, P2, P3, P4), T1 arg1, T2 arg2, T3 arg3, T4 arg4) { - return std::unique_ptr<Closure4<P1, P2, P3, P4, R> >( - new MemberClosure4_4<Ptr, Obj, T1, T2, T3, T4, P1, P2, P3, P4, R>( - std::move(ptr), mem_fun, std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4))); -} - -} // namespace vespalib - - diff --git a/vespalib/src/vespa/vespalib/util/closuretask.cpp b/vespalib/src/vespa/vespalib/util/closuretask.cpp deleted file mode 100644 index ecffa2f3df8..00000000000 --- a/vespalib/src/vespa/vespalib/util/closuretask.cpp +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - -#include "closuretask.h" - -namespace vespalib { - -ClosureTask::~ClosureTask() {} - -Executor::Task::UP makeTask(std::unique_ptr<Closure> closure) { - return Executor::Task::UP(new ClosureTask(std::move(closure))); -} - -} diff --git a/vespalib/src/vespa/vespalib/util/closuretask.h b/vespalib/src/vespa/vespalib/util/closuretask.h deleted file mode 100644 index 4ff0ec7694b..00000000000 --- a/vespalib/src/vespa/vespalib/util/closuretask.h +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - -#pragma once - -#include "closure.h" -#include "executor.h" - -namespace vespalib { - -/** - * Wrapper class for using closures as tasks to an executor. - **/ -class ClosureTask : public Executor::Task { - std::unique_ptr<Closure> _closure; - -public: - ClosureTask(std::unique_ptr<Closure> closure) : _closure(std::move(closure)) {} - ~ClosureTask(); - void run() override { _closure->call(); } -}; - -/** - * Wraps a Closure as an Executor::Task. - **/ -Executor::Task::UP makeTask(std::unique_ptr<Closure> closure); - -} // namespace vespalib - diff --git a/vespalib/src/vespa/vespalib/util/overview.h b/vespalib/src/vespa/vespalib/util/overview.h index 311071b4429..d67a6a33998 100644 --- a/vespalib/src/vespa/vespalib/util/overview.h +++ b/vespalib/src/vespa/vespalib/util/overview.h @@ -56,11 +56,4 @@ * vespalib::Utf8Reader * <BR> vespalib::Utf8Writer * <BR> vespalib::LowerCase - * - * Closures and closure handling - * - * vespalib::Closure0 - * <BR> vespalib::MemberClosure0_0 - * <BR> vespalib::ClosureTask - * <BR> vespalib::AutoClosureCaller */ |