diff options
author | Murray Cumming <murrayc@murrayc.com> | 2016-03-07 11:38:52 +0100 |
---|---|---|
committer | Murray Cumming <murrayc@murrayc.com> | 2016-03-10 13:50:29 +0100 |
commit | 0d304b484918d607ffbbc81696a9e3321dff4ad0 (patch) | |
tree | ab69a8f17ef1cfe5f5eed783a2c366bd4f026076 | |
parent | 97df7e3637af7355b51db89e5ebf119742f23681 (diff) | |
download | sigc++-0d304b484918d607ffbbc81696a9e3321dff4ad0.tar.gz |
mem_fun(): Remove the T_obj* overloads.
So you would, for instance, always call sigc::mem_fun(*this, ...)
instead of sigc::mem_fun(this, ...).
Bug #763215
-rw-r--r-- | examples/member_method.cc | 2 | ||||
-rw-r--r-- | sigc++/functors/mem_fun.h | 66 | ||||
-rw-r--r-- | tests/test_accumulated.cc | 4 | ||||
-rw-r--r-- | tests/test_bind_refptr.cc | 4 | ||||
-rw-r--r-- | tests/test_disconnect.cc | 14 | ||||
-rw-r--r-- | tests/test_limit_reference.cc | 2 | ||||
-rw-r--r-- | tests/test_mem_fun.cc | 8 | ||||
-rw-r--r-- | tests/test_signal.cc | 4 | ||||
-rw-r--r-- | tests/test_trackable.cc | 2 | ||||
-rw-r--r-- | tests/test_trackable_move.cc | 4 | ||||
-rw-r--r-- | tests/test_visit_each.cc | 6 |
11 files changed, 25 insertions, 91 deletions
diff --git a/examples/member_method.cc b/examples/member_method.cc index 5794a9e..bee4f1b 100644 --- a/examples/member_method.cc +++ b/examples/member_method.cc @@ -25,7 +25,7 @@ protected: Something::Something() { - auto iter = signal_print.connect( sigc::mem_fun(this, &Something::on_print) ); + auto iter = signal_print.connect( sigc::mem_fun(*this, &Something::on_print) ); signal_print.emit(2); diff --git a/sigc++/functors/mem_fun.h b/sigc++/functors/mem_fun.h index 2701959..fe6973f 100644 --- a/sigc++/functors/mem_fun.h +++ b/sigc++/functors/mem_fun.h @@ -227,23 +227,6 @@ mem_fun(T_return (T_obj::*_A_func)(T_arg...) const volatile) T_arg...>(_A_func); } - -/** Creates a functor of type sigc::bound_mem_functor which encapsulates a method and an object instance. - * @param _A_obj Pointer to object instance the functor should operate on. - * @param _A_func Pointer to method that should be wrapped. - * @return Functor that executes @e _A_func on invokation. - * - * @ingroup mem_fun - */ -template <class T_return, class T_obj, class T_obj2, class... T_arg> -inline decltype(auto) -mem_fun(/**/ T_obj* _A_obj, T_return (T_obj2::*_A_func)(T_arg...) ) -{ - return bound_mem_functor< - T_return (T_obj::*)(T_arg...) , - T_arg...>(*_A_obj, _A_func); -} - /** Creates a functor of type sigc::bound_mem_functor which encapsulates a method and an object instance. * @param _A_obj Reference to object instance the functor should operate on. * @param _A_func Pointer to method that should be wrapped. @@ -260,23 +243,6 @@ mem_fun(/**/ T_obj& _A_obj, T_return (T_obj2::*_A_func)(T_arg...) ) T_arg...>(_A_obj, _A_func); } - -/** Creates a functor of type sigc::bound_const_mem_functor which encapsulates a method and an object instance. - * @param _A_obj Pointer to object instance the functor should operate on. - * @param _A_func Pointer to method that should be wrapped. - * @return Functor that executes @e _A_func on invokation. - * - * @ingroup mem_fun - */ -template <class T_return, class T_obj, class T_obj2, class... T_arg> -inline decltype(auto) -mem_fun(/*const*/ T_obj* _A_obj, T_return (T_obj2::*_A_func)(T_arg...) const) -{ - return bound_mem_functor< - T_return (T_obj::*)(T_arg...) const, - T_arg...>(*_A_obj, _A_func); -} - /** Creates a functor of type sigc::bound_const_mem_functor which encapsulates a method and an object instance. * @param _A_obj Reference to object instance the functor should operate on. * @param _A_func Pointer to method that should be wrapped. @@ -295,22 +261,6 @@ mem_fun(/*const*/ T_obj& _A_obj, T_return (T_obj2::*_A_func)(T_arg...) const) /** Creates a functor of type sigc::bound_volatile_mem_functor which encapsulates a method and an object instance. - * @param _A_obj Pointer to object instance the functor should operate on. - * @param _A_func Pointer to method that should be wrapped. - * @return Functor that executes @e _A_func on invokation. - * - * @ingroup mem_fun - */ -template <class T_return, class T_obj, class T_obj2, class... T_arg> -inline decltype(auto) -mem_fun(/**/ T_obj* _A_obj, T_return (T_obj2::*_A_func)(T_arg...) volatile) -{ - return bound_mem_functor< - T_return (T_obj::*)(T_arg...) volatile, - T_arg...>(*_A_obj, _A_func); -} - -/** Creates a functor of type sigc::bound_volatile_mem_functor which encapsulates a method and an object instance. * @param _A_obj Reference to object instance the functor should operate on. * @param _A_func Pointer to method that should be wrapped. * @return Functor that executes @e _A_func on invokation. @@ -328,22 +278,6 @@ mem_fun(/**/ T_obj& _A_obj, T_return (T_obj2::*_A_func)(T_arg...) volatile) /** Creates a functor of type sigc::bound_const_volatile_mem_functor which encapsulates a method and an object instance. - * @param _A_obj Pointer to object instance the functor should operate on. - * @param _A_func Pointer to method that should be wrapped. - * @return Functor that executes @e _A_func on invokation. - * - * @ingroup mem_fun - */ -template <class T_return, class T_obj, class T_obj2, class... T_arg> -inline decltype(auto) -mem_fun(/*const*/ T_obj* _A_obj, T_return (T_obj2::*_A_func)(T_arg...) const volatile) -{ - return bound_mem_functor< - T_return (T_obj::*)(T_arg...) const volatile, - T_arg...>(*_A_obj, _A_func); -} - -/** Creates a functor of type sigc::bound_const_volatile_mem_functor which encapsulates a method and an object instance. * @param _A_obj Reference to object instance the functor should operate on. * @param _A_func Pointer to method that should be wrapped. * @return Functor that executes @e _A_func on invokation. diff --git a/tests/test_accumulated.cc b/tests/test_accumulated.cc index 1efa979..5ada9fc 100644 --- a/tests/test_accumulated.cc +++ b/tests/test_accumulated.cc @@ -89,11 +89,11 @@ int main(int argc, char* argv[]) A a; sig.connect(sigc::ptr_fun(&foo)); - sig.connect(sigc::mem_fun(&a, &A::foo)); + sig.connect(sigc::mem_fun(a, &A::foo)); sig.connect(sigc::ptr_fun(&bar)); sig_vec.connect(sigc::ptr_fun(&foo)); - sig_vec.connect(sigc::mem_fun(&a, &A::foo)); + sig_vec.connect(sigc::mem_fun(a, &A::foo)); sig_vec.connect(sigc::ptr_fun(&bar)); double dres = sig(1); diff --git a/tests/test_bind_refptr.cc b/tests/test_bind_refptr.cc index f8fe446..a8909af 100644 --- a/tests/test_bind_refptr.cc +++ b/tests/test_bind_refptr.cc @@ -441,10 +441,10 @@ public: { result_stream << "new Test; "; #ifdef ACTIVATE_BUG //See https://bugzilla.gnome.org/show_bug.cgi?id=564005#c14 - action->signal_sig1().connect(sigc::bind(sigc::mem_fun(this, &Test::on_sig1), action)); + action->signal_sig1().connect(sigc::bind(sigc::mem_fun(*this, &Test::on_sig1), action)); #else Glib::RefPtr<Action> action2(new Action); - action->signal_sig1().connect(sigc::bind(sigc::mem_fun(this, &Test::on_sig1), action2)); + action->signal_sig1().connect(sigc::bind(sigc::mem_fun(*this, &Test::on_sig1), action2)); #endif } diff --git a/tests/test_disconnect.cc b/tests/test_disconnect.cc index 40a092a..70cf786 100644 --- a/tests/test_disconnect.cc +++ b/tests/test_disconnect.cc @@ -50,8 +50,8 @@ struct B : public sigc::trackable { B() { - sig.connect(sigc::mem_fun(this, &B::destroy)); - sig.connect(sigc::mem_fun(this, &B::boom)); + sig.connect(sigc::mem_fun(*this, &B::destroy)); + sig.connect(sigc::mem_fun(*this, &B::boom)); sig.connect(sigc::ptr_fun(&good_bye_world)); } @@ -89,7 +89,7 @@ int main(int argc, char* argv[]) { A a; - sig.connect(sigc::mem_fun(&a, &A::foo)); + sig.connect(sigc::mem_fun(a, &A::foo)); confoo = sig.connect(sigc::ptr_fun(&foo)); conbar = sig.connect(sigc::ptr_fun(&bar)); result_stream << "sig is connected to A::foo, foo, bar (size=" << sig.size() << "): "; @@ -103,7 +103,7 @@ int main(int argc, char* argv[]) util->check_result(result_stream, "sig is connected to foo, bar (size=2): foo(2) bar(2) "); A a; // iterators stay valid after further connections. - cona = sig.slots().insert(conbar, sigc::mem_fun(&a, &A::foo)); + cona = sig.slots().insert(conbar, sigc::mem_fun(a, &A::foo)); result_stream << "sig is connected to foo, A::foo, bar (size=" << sig.size() << "): "; sig(3); util->check_result(result_stream, @@ -128,7 +128,7 @@ int main(int argc, char* argv[]) { A a2; - sig.connect(sigc::compose(sigc::mem_fun(&a2, &A::foo), &foo)); + sig.connect(sigc::compose(sigc::mem_fun(a2, &A::foo), &foo)); result_stream << "sig is connected to compose(A::foo, foo) (size=" << sig.size() << "): "; sig(7); util->check_result(result_stream, "sig is connected to compose(A::foo, foo) (size=1): foo(7) A::foo(1) "); @@ -139,7 +139,7 @@ int main(int argc, char* argv[]) { // A slot# within a slot A a2; - sigc::slot<int, int> setter = sigc::mem_fun(&a2, &A::foo); + sigc::slot<int, int> setter = sigc::mem_fun(a2, &A::foo); sig.connect(sigc::compose(setter, &foo)); result_stream << "sig is connected to compose(slot1(A::foo), foo) (size=" << sig.size() << "): "; sig(9); @@ -151,7 +151,7 @@ int main(int argc, char* argv[]) { // A slot within a slot A a2; - sigc::slot<int, int> setter = sigc::mem_fun(&a2, &A::foo); + sigc::slot<int, int> setter = sigc::mem_fun(a2, &A::foo); sig.connect(sigc::compose(setter, &foo)); result_stream << "sig is connected to compose(slot(A::foo), foo) (size=" << sig.size() << "): "; sig(11); diff --git a/tests/test_limit_reference.cc b/tests/test_limit_reference.cc index 34fa547..ea1edcd 100644 --- a/tests/test_limit_reference.cc +++ b/tests/test_limit_reference.cc @@ -41,7 +41,7 @@ int main(int argc, char* argv[]) return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE; auto instance = new Derived(); - sigc::slot<void> handler = sigc::mem_fun(instance, &Derived::method); + sigc::slot<void> handler = sigc::mem_fun(*instance, &Derived::method); handler(); util->check_result(result_stream, "method()"); diff --git a/tests/test_mem_fun.cc b/tests/test_mem_fun.cc index b8fe8b9..2d8d3a3 100644 --- a/tests/test_mem_fun.cc +++ b/tests/test_mem_fun.cc @@ -134,26 +134,26 @@ int main(int argc, char* argv[]) sigc::mem_fun(t, &test::foo)(9); util->check_result(result_stream, "test::foo(short 9)"); - sigc::mem_fun(&t, &test::foo)(9); + sigc::mem_fun(t, &test::foo)(9); util->check_result(result_stream, "test::foo(short 9)"); sigc::mem_fun(t, &test::foo_const)(9); util->check_result(result_stream, "test::foo_const(int 9)"); - sigc::mem_fun(&t, &test::foo_const)(9); + sigc::mem_fun(t, &test::foo_const)(9); util->check_result(result_stream, "test::foo_const(int 9)"); sigc::mem_fun(t, &test::foo_volatile)(9); util->check_result(result_stream, "test::foo_volatile(float 9)"); - sigc::mem_fun(&t, &test::foo_volatile)(9); + sigc::mem_fun(t, &test::foo_volatile)(9); util->check_result(result_stream, "test::foo_volatile(float 9)"); #if ENABLE_TEST_OF_OVERLOADED_FUNCTIONS sigc::mem_fun(t, &test::foo_overloaded)(9, 10); util->check_result(result_stream, "test::foo_overloaded(int 9, int 10)"); - sigc::mem_fun(&t, &test::foo_overloaded)(9, 10); + sigc::mem_fun(t, &test::foo_overloaded)(9, 10); util->check_result(result_stream, "test::foo_overloaded(int 9, int 10)"); #endif } diff --git a/tests/test_signal.cc b/tests/test_signal.cc index ecb5a55..1235a29 100644 --- a/tests/test_signal.cc +++ b/tests/test_signal.cc @@ -62,7 +62,7 @@ int main(int argc, char* argv[]) { A a; sig.connect(sigc::ptr_fun(&foo)); - sig.connect(sigc::mem_fun(&a, &A::foo)); + sig.connect(sigc::mem_fun(a, &A::foo)); sig.connect(sigc::ptr_fun(&bar)); sig(1); result_stream << sig.size(); @@ -78,7 +78,7 @@ int main(int argc, char* argv[]) A a; std::string str("guest book"); sigc::signal<void,std::string&> sigstr; - sigstr.connect(sigc::mem_fun(&a, &A::bar)); + sigstr.connect(sigc::mem_fun(a, &A::bar)); sigstr(str); result_stream << str; util->check_result(result_stream, "A::foo(string 'guest book') foo was here"); diff --git a/tests/test_trackable.cc b/tests/test_trackable.cc index fe7ecb1..6677c43 100644 --- a/tests/test_trackable.cc +++ b/tests/test_trackable.cc @@ -38,7 +38,7 @@ int main(int argc, char* argv[]) { my_class t; t.i = 10; - sl = sigc::mem_fun(&t, &my_class::foo); + sl = sigc::mem_fun(t, &my_class::foo); sl(); util->check_result(result_stream, "10"); } diff --git a/tests/test_trackable_move.cc b/tests/test_trackable_move.cc index 6ed2e26..d42b9c3 100644 --- a/tests/test_trackable_move.cc +++ b/tests/test_trackable_move.cc @@ -61,7 +61,7 @@ int main(int argc, char* argv[]) { my_class t; t.i = 10; - sl = sigc::mem_fun(&t, &my_class::foo); + sl = sigc::mem_fun(t, &my_class::foo); sl(); util->check_result(result_stream, "10"); @@ -70,7 +70,7 @@ int main(int argc, char* argv[]) t2.i = 15; result_stream.clear(); - sl = sigc::mem_fun(&t2, &my_class::foo); + sl = sigc::mem_fun(t2, &my_class::foo); sl(); util->check_result(result_stream, "15"); diff --git a/tests/test_visit_each.cc b/tests/test_visit_each.cc index add80a5..4c508b6 100644 --- a/tests/test_visit_each.cc +++ b/tests/test_visit_each.cc @@ -164,7 +164,7 @@ int main(int argc, char* argv[]) { MyClass1 my_class1("x="); - sl1 = sigc::mem_fun(&my_class1, &MyClass1::execute); + sl1 = sigc::mem_fun(my_class1, &MyClass1::execute); sl1(-2); util->check_result(result_stream, "x=-2"); @@ -176,7 +176,7 @@ int main(int argc, char* argv[]) #if SIGCTEST_CASE >= 2 { MyClass2 my_class2("y="); - sl1 = sigc::mem_fun(&my_class2, &MyClass2::execute); + sl1 = sigc::mem_fun(my_class2, &MyClass2::execute); sl1(2); util->check_result(result_stream, "y=2"); @@ -188,7 +188,7 @@ int main(int argc, char* argv[]) { MyClass1 my_class3("a="); - sl1 = ns1::my_adaptor1(sigc::mem_fun(&my_class3, &MyClass1::execute)); + sl1 = ns1::my_adaptor1(sigc::mem_fun(my_class3, &MyClass1::execute)); sl1(42); util->check_result(result_stream, "MyAdaptor1()(_A_arg1) a=42"); |