diff options
author | Murray Cumming <murrayc@murrayc.com> | 2016-03-10 17:32:55 +0100 |
---|---|---|
committer | Murray Cumming <murrayc@murrayc.com> | 2016-03-10 17:32:55 +0100 |
commit | 7dbe9c3c825c6892a96557a09ddec199ab4c4019 (patch) | |
tree | d01864a80b16618551d23f9230513b9f57adebab | |
parent | ee10e818ea7de842b7c7276caf841232d795a74c (diff) | |
download | sigc++-7dbe9c3c825c6892a96557a09ddec199ab4c4019.tar.gz |
tests: Use std::ref() instead of deprecated sigc::ref().
-rw-r--r-- | sigc++/visit_each.h | 4 | ||||
-rw-r--r-- | tests/test_bind.cc | 6 | ||||
-rw-r--r-- | tests/test_bind_ref.cc | 8 | ||||
-rw-r--r-- | tests/test_bind_return.cc | 6 | ||||
-rw-r--r-- | tests/test_copy_invalid_slot.cc | 2 | ||||
-rw-r--r-- | tests/test_cpp11_lambda.cc | 28 | ||||
-rw-r--r-- | tests/test_functor_trait.cc | 6 | ||||
-rw-r--r-- | tests/test_limit_reference.cc | 4 | ||||
-rw-r--r-- | tests/test_track_obj.cc | 4 |
9 files changed, 34 insertions, 34 deletions
diff --git a/sigc++/visit_each.h b/sigc++/visit_each.h index 82f4236..ab681cb 100644 --- a/sigc++/visit_each.h +++ b/sigc++/visit_each.h @@ -181,12 +181,12 @@ void visit_each_type(const T_action& _A_action, const T_functor& _A_functor) type_limited_action limited_action(_A_action); - //specifying the types of the template specialization prevents disconnection of bound trackable references (such as with sigc::ref()), + //specifying the types of the template specialization prevents disconnection of bound trackable references (such as with std::ref()), //probably because the visit_each<> specializations take various different template types, //in various sequences, and we are probably specifying only a subset of them with this. // //But this is required by the AIX (and maybe IRIX MipsPro and Tru64) compilers. - //I guess that sigc::ref() therefore does not work on those platforms. murrayc + //I guess that std::ref() therefore does not work on those platforms. murrayc // sigc::visit_each<type_limited_action, T_functor>(limited_action, _A_functor); //g++ (even slightly old ones) is our primary platform, so we could use the non-crashing version. diff --git a/tests/test_bind.cc b/tests/test_bind.cc index 845d54c..2d3862b 100644 --- a/tests/test_bind.cc +++ b/tests/test_bind.cc @@ -130,7 +130,7 @@ int main(int argc, char* argv[]) // method pointer instead of functor book test_book("otto"); - result_stream << sigc::bind<0>(&book::get_name, sigc::ref(test_book))(); + result_stream << sigc::bind<0>(&book::get_name, std::ref(test_book))(); util->check_result(result_stream, "otto"); // test return type of bind_functor::operator() overload with no arguments @@ -142,14 +142,14 @@ int main(int argc, char* argv[]) // test references std::string str("guest book"); - sigc::bind(&egon, sigc::ref(str))(); // Tell bind that it shall store a reference. + sigc::bind(&egon, std::ref(str))(); // Tell bind that it shall store a reference. result_stream << " " << str; // (This cannot be the default behaviour: just think about what happens if str dies!) util->check_result(result_stream, "egon(string 'guest book') egon was here"); sigc::slot<void> sl; { book guest_book("karl"); - sl = sigc::bind(&egon, sigc::ref(guest_book)); + sl = sigc::bind(&egon, std::ref(guest_book)); sl(); result_stream << " " << static_cast<std::string&>(guest_book); util->check_result(result_stream, "egon(string 'karl') egon was here"); diff --git a/tests/test_bind_ref.cc b/tests/test_bind_ref.cc index 58bd55d..abac4cb 100644 --- a/tests/test_bind_ref.cc +++ b/tests/test_bind_ref.cc @@ -16,7 +16,7 @@ public: {} //non-copyable, - //so it can only be used with sigc::bind() via sigc::ref() + //so it can only be used with sigc::bind() via std::ref() Param(const Param&) = delete; Param& operator=(const Param&) = delete; @@ -48,12 +48,12 @@ int main(int argc, char* argv[]) util->check_result(result_stream, ""); { - //Because Param derives from sigc::trackable(), sigc::ref() should disconnect + //Because Param derives from sigc::trackable(), std::ref() should disconnect // the signal handler when param is destroyed. Param param("murrayc"); // A convoluted way to do - // slot_bound = sigc::bind(slot_full, sigc::ref(param)); - slot_bound = sigc::bind< -1, sigc::reference_wrapper<Param> >(slot_full, sigc::ref(param)); + // slot_bound = sigc::bind(slot_full, std::ref(param)); + slot_bound = sigc::bind< -1, std::reference_wrapper<Param> >(slot_full, std::ref(param)); result_stream << "Calling slot when param exists:"; slot_bound(); diff --git a/tests/test_bind_return.cc b/tests/test_bind_return.cc index 88c85ae..96e67a8 100644 --- a/tests/test_bind_return.cc +++ b/tests/test_bind_return.cc @@ -52,8 +52,8 @@ int main(int argc, char* argv[]) // references. std::string str("guest book"); // A convoluted way to do - // sigc::bind_return(foo(), sigc::ref(str))(6) = "main"; - sigc::bind_return<sigc::reference_wrapper<std::string> >(foo(), sigc::ref(str))(6) = "main"; + // sigc::bind_return(foo(), std::ref(str))(6) = "main"; + sigc::bind_return<std::reference_wrapper<std::string> >(foo(), std::ref(str))(6) = "main"; result_stream << str; util->check_result(result_stream, "foo(int 6) main"); @@ -67,7 +67,7 @@ int main(int argc, char* argv[]) sigc::slot<bar, int> sl; { bar choco(-1); - sl = sigc::bind_return(foo(),sigc::ref(choco)); + sl = sigc::bind_return(foo(),std::ref(choco)); result_stream << sl(7); util->check_result(result_stream, "foo(int 7) -1"); } // auto-disconnect diff --git a/tests/test_copy_invalid_slot.cc b/tests/test_copy_invalid_slot.cc index b480a15..b67c83e 100644 --- a/tests/test_copy_invalid_slot.cc +++ b/tests/test_copy_invalid_slot.cc @@ -30,7 +30,7 @@ int main(int argc, char* argv[]) util->check_result(result_stream, "sigc::trackable instance at " + pointer_stream.str()); pointer_stream.str(""); - sigc::slot<void> foo = sigc::bind(sigc::ptr_fun(Foo), sigc::ref(*t)); + sigc::slot<void> foo = sigc::bind(sigc::ptr_fun(Foo), std::ref(*t)); foo(); util->check_result(result_stream, "Foo(x)"); diff --git a/tests/test_cpp11_lambda.cc b/tests/test_cpp11_lambda.cc index e97b80e..2e4acf8 100644 --- a/tests/test_cpp11_lambda.cc +++ b/tests/test_cpp11_lambda.cc @@ -182,9 +182,9 @@ int main(int argc, char* argv[]) result_stream << ([] (int x) -> int { return ++x * 2; }(a_outer)) << " " << a_outer; util->check_result(result_stream, "4 1"); - // gcc can't compile libsigc++ lambda expressions with sigc::ref() parameters. + // gcc can't compile libsigc++ lambda expressions with std::ref() parameters. // See https://bugzilla.gnome.org/show_bug.cgi?id=669128 - // std::cout << "((++_1)*2)(ref(a)): " << ((++_1)*2)(sigc::ref(a)); + // std::cout << "((++_1)*2)(ref(a)): " << ((++_1)*2)(std::ref(a)); // std::cout << "; a: " << a << std::endl; result_stream << ([] (std::reference_wrapper<int> x) -> int { return ++x * 2; }(std::ref(a_outer))); result_stream << " " << a_outer; @@ -199,7 +199,7 @@ int main(int argc, char* argv[]) result_stream << " " << a_outer; util->check_result(result_stream, "8 4"); - // std::cout << "((--(*(&_1)))*2)(ref(a)): " << ((--(*(&_1)))*2)(sigc::ref(a)); + // std::cout << "((--(*(&_1)))*2)(ref(a)): " << ((--(*(&_1)))*2)(std::ref(a)); // std::cout << "; a: " << a << std::endl; result_stream << ([] (std::reference_wrapper<int> x) -> int { return --(*(&x)) * 2; }(std::ref(a_outer))); result_stream << " " << a_outer; @@ -241,15 +241,15 @@ int main(int argc, char* argv[]) // - var() is used to create a lambda that holds a reference and is interchangable with ref() in lambda operator expressions // - cannot use std::endl without much hackery because it is defined as a template function // - cannot use "\n" without var() because arrays cannot be copied - // (sigc::ref(std::cout) << sigc::constant(1) << sigc::var("\n"))(); + // (std::ref(std::cout) << sigc::constant(1) << sigc::var("\n"))(); [](){ result_stream << 1 << "\n"; }(); util->check_result(result_stream, "1\n"); - //(sigc::ref(std::cout) << _1 << std::string("\n"))("hello world"); + //(std::ref(std::cout) << _1 << std::string("\n"))("hello world"); [](const char* a){ result_stream << a << std::string("\n"); }("hello world"); util->check_result(result_stream, "hello world\n"); - //(sigc::ref(std::cout) << sigc::static_cast_<int>(_1) << std::string("\n"))(1.234); + //(std::ref(std::cout) << sigc::static_cast_<int>(_1) << std::string("\n"))(1.234); [](double a){ result_stream << static_cast<int>(a) << std::string("\n"); }(1.234); util->check_result(result_stream, "1\n"); @@ -269,7 +269,7 @@ int main(int argc, char* argv[]) sigc::slot<void, std::ostringstream&> sl1; { book guest_book("karl"); - //sl1 = (sigc::var(std::cout) << sigc::ref(guest_book) << sigc::var("\n")); + //sl1 = (sigc::var(std::cout) << std::ref(guest_book) << sigc::var("\n")); // sl1 = [&guest_book](std::ostringstream& stream){ stream << guest_book << "\n"; }; // no auto-disconnect sl1 = sigc::track_obj([&guest_book](std::ostringstream& stream){ stream << guest_book << "\n"; }, guest_book); sl1(result_stream); @@ -290,7 +290,7 @@ int main(int argc, char* argv[]) result_stream << std::bind(&foo, std::placeholders::_2, std::placeholders::_1)(1, 2); util->check_result(result_stream, "foo(int 2, int 1) 9"); - //std::cout << (sigc::group(sigc::mem_fun(&bar::test), _1, _2, _3)) (sigc::ref(the_bar), 1, 2) << std::endl; + //std::cout << (sigc::group(sigc::mem_fun(&bar::test), _1, _2, _3)) (std::ref(the_bar), 1, 2) << std::endl; // std::ref(the_bar) is not necessary. It can make the call ambiguous. // Even without std::ref() the_bar is not copied. result_stream << std::bind(std::mem_fn(&bar::test), std::placeholders::_1, @@ -320,7 +320,7 @@ int main(int argc, char* argv[]) sigc::slot<void> sl2; { book guest_book("karl"); - //sl2 = sigc::group(&egon, sigc::ref(guest_book)); + //sl2 = sigc::group(&egon, std::ref(guest_book)); // sl2 = [&guest_book] () { egon(guest_book); }; // no auto-disconnect // sl2 = std::bind(&egon, std::ref(guest_book)); // does not compile (gcc 4.6.3) sl2 = sigc::track_obj([&guest_book] () { egon(guest_book); }, guest_book); @@ -339,7 +339,7 @@ int main(int argc, char* argv[]) // More auto-disconnect { book guest_book("charlie"); - //sl2 = sigc::group(&egon, sigc::ref(guest_book)); + //sl2 = sigc::group(&egon, std::ref(guest_book)); // sl2 = std::bind(&egon, std::ref(guest_book)); // does not compile (gcc 4.6.3) auto fn2 = std::bind(&egon, std::ref(guest_book)); //sl2 = fn2; // no auto-disconnect @@ -469,9 +469,9 @@ int main(int argc, char* argv[]) { int some_int = 0; sigc::signal<void> some_signal; - //some_signal.connect(sigc::group(&foo,sigc::ref(some_int))); + //some_signal.connect(sigc::group(&foo,std::ref(some_int))); //some_signal.connect(std::bind(&foo_group3, std::ref(some_int))); // does not compile (gcc 4.6.3) - //some_signal.connect(sigc::bind(&foo_group3, sigc::ref(some_int))); // compiles, but we prefer std::bind() or C++11 lambda + //some_signal.connect(sigc::bind(&foo_group3, std::ref(some_int))); // compiles, but we prefer std::bind() or C++11 lambda some_signal.connect([&some_int](){ foo_group3(some_int); }); some_signal.emit(); result_stream << " " << some_int; @@ -483,10 +483,10 @@ int main(int argc, char* argv[]) sigc::signal<void> some_signal; { bar_group4 some_bar; - //some_signal.connect(sigc::group(&foo,sigc::ref(some_bar))); + //some_signal.connect(sigc::group(&foo,std::ref(some_bar))); // disconnected automatically if some_bar goes out of scope //some_signal.connect([&some_bar](){ foo_group4(some_bar); }); // no auto-disconnect - //some_signal.connect(sigc::bind(&foo_group4, sigc::ref(some_bar))); // auto-disconnects, but we prefer C++11 lambda + //some_signal.connect(sigc::bind(&foo_group4, std::ref(some_bar))); // auto-disconnects, but we prefer C++11 lambda some_signal.connect(sigc::track_obj([&some_bar](){ foo_group4(some_bar); }, some_bar)); some_signal.emit(); util->check_result(result_stream, "foo_group4(bar_group4&)"); diff --git a/tests/test_functor_trait.cc b/tests/test_functor_trait.cc index bf3b26e..2eb2eaa 100644 --- a/tests/test_functor_trait.cc +++ b/tests/test_functor_trait.cc @@ -83,15 +83,15 @@ int main(int argc, char* argv[]) int k = 3; A a; result_stream << "hit all targets: "; - sigc::visit_each(print(), sigc::compose(sigc::bind(sigc::ptr_fun3(&foo), sigc::ref(a), i), sigc::ptr_fun1(&bar))); + sigc::visit_each(print(), sigc::compose(sigc::bind(sigc::ptr_fun3(&foo), std::ref(a), i), sigc::ptr_fun1(&bar))); util->check_result(result_stream, "hit all targets: other trackable int: 1 other "); result_stream << "hit all ints: "; - sigc::visit_each_type<int>(print(), sigc::compose(sigc::bind(sigc::ptr_fun3(&foo), sigc::ref(a), j),sigc::ptr_fun1(&bar))); + sigc::visit_each_type<int>(print(), sigc::compose(sigc::bind(sigc::ptr_fun3(&foo), std::ref(a), j),sigc::ptr_fun1(&bar))); util->check_result(result_stream, "hit all ints: int: 2 "); result_stream << "hit all trackable: "; - sigc::visit_each_type<trackable>(print(), sigc::compose(sigc::bind(sigc::ptr_fun3(&foo), sigc::ref(a), k),sigc::ptr_fun1(&bar))); + sigc::visit_each_type<trackable>(print(), sigc::compose(sigc::bind(sigc::ptr_fun3(&foo), std::ref(a), k),sigc::ptr_fun1(&bar))); util->check_result(result_stream, "hit all trackable: trackable "); return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE; diff --git a/tests/test_limit_reference.cc b/tests/test_limit_reference.cc index d72efd1..d8f3539 100644 --- a/tests/test_limit_reference.cc +++ b/tests/test_limit_reference.cc @@ -45,12 +45,12 @@ int main(int argc, char* argv[]) util->check_result(result_stream, "method()"); auto param = - sigc::bind(sigc::slot<void, Derived&>(), sigc::ref(*instance)); + sigc::bind(sigc::slot<void, Derived&>(), std::ref(*instance)); param(); util->check_result(result_stream, ""); auto ret = - sigc::bind_return(sigc::slot<void>(), sigc::ref(*instance)); + sigc::bind_return(sigc::slot<void>(), std::ref(*instance)); ret(); util->check_result(result_stream, ""); diff --git a/tests/test_track_obj.cc b/tests/test_track_obj.cc index a6ce6ed..b0f6e9e 100644 --- a/tests/test_track_obj.cc +++ b/tests/test_track_obj.cc @@ -202,10 +202,10 @@ int main(int argc, char* argv[]) sigc::signal<void> some_signal; { bar_group4 some_bar; - //some_signal.connect(sigc::group(&foo,sigc::ref(some_bar))); + //some_signal.connect(sigc::group(&foo,std::ref(some_bar))); // disconnected automatically if some_bar goes out of scope //some_signal.connect([&some_bar](){ foo_group4(some_bar); }); // no auto-disconnect - //some_signal.connect(sigc::bind(&foo_group4, sigc::ref(some_bar))); // auto-disconnects, but we prefer C++11 lambda + //some_signal.connect(sigc::bind(&foo_group4, std::ref(some_bar))); // auto-disconnects, but we prefer C++11 lambda some_signal.connect(sigc::track_obj([&some_bar](){ foo_group4(some_bar); }, some_bar)); some_signal.emit(); util->check_result(result_stream, "foo_group4(bar_group4&)"); |