Skip to content

Commit 7dbe9c3

Browse files
committed
tests: Use std::ref() instead of deprecated sigc::ref().
1 parent ee10e81 commit 7dbe9c3

9 files changed

+34
-34
lines changed

sigc++/visit_each.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,12 +181,12 @@ void visit_each_type(const T_action& _A_action, const T_functor& _A_functor)
181181

182182
type_limited_action limited_action(_A_action);
183183

184-
//specifying the types of the template specialization prevents disconnection of bound trackable references (such as with sigc::ref()),
184+
//specifying the types of the template specialization prevents disconnection of bound trackable references (such as with std::ref()),
185185
//probably because the visit_each<> specializations take various different template types,
186186
//in various sequences, and we are probably specifying only a subset of them with this.
187187
//
188188
//But this is required by the AIX (and maybe IRIX MipsPro and Tru64) compilers.
189-
//I guess that sigc::ref() therefore does not work on those platforms. murrayc
189+
//I guess that std::ref() therefore does not work on those platforms. murrayc
190190
// sigc::visit_each<type_limited_action, T_functor>(limited_action, _A_functor);
191191

192192
//g++ (even slightly old ones) is our primary platform, so we could use the non-crashing version.

tests/test_bind.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ int main(int argc, char* argv[])
130130

131131
// method pointer instead of functor
132132
book test_book("otto");
133-
result_stream << sigc::bind<0>(&book::get_name, sigc::ref(test_book))();
133+
result_stream << sigc::bind<0>(&book::get_name, std::ref(test_book))();
134134
util->check_result(result_stream, "otto");
135135

136136
// test return type of bind_functor::operator() overload with no arguments
@@ -142,14 +142,14 @@ int main(int argc, char* argv[])
142142

143143
// test references
144144
std::string str("guest book");
145-
sigc::bind(&egon, sigc::ref(str))(); // Tell bind that it shall store a reference.
145+
sigc::bind(&egon, std::ref(str))(); // Tell bind that it shall store a reference.
146146
result_stream << " " << str; // (This cannot be the default behaviour: just think about what happens if str dies!)
147147
util->check_result(result_stream, "egon(string 'guest book') egon was here");
148148

149149
sigc::slot<void> sl;
150150
{
151151
book guest_book("karl");
152-
sl = sigc::bind(&egon, sigc::ref(guest_book));
152+
sl = sigc::bind(&egon, std::ref(guest_book));
153153
sl();
154154
result_stream << " " << static_cast<std::string&>(guest_book);
155155
util->check_result(result_stream, "egon(string 'karl') egon was here");

tests/test_bind_ref.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class Param : public sigc::trackable
1616
{}
1717

1818
//non-copyable,
19-
//so it can only be used with sigc::bind() via sigc::ref()
19+
//so it can only be used with sigc::bind() via std::ref()
2020
Param(const Param&) = delete;
2121
Param& operator=(const Param&) = delete;
2222

@@ -48,12 +48,12 @@ int main(int argc, char* argv[])
4848
util->check_result(result_stream, "");
4949

5050
{
51-
//Because Param derives from sigc::trackable(), sigc::ref() should disconnect
51+
//Because Param derives from sigc::trackable(), std::ref() should disconnect
5252
// the signal handler when param is destroyed.
5353
Param param("murrayc");
5454
// A convoluted way to do
55-
// slot_bound = sigc::bind(slot_full, sigc::ref(param));
56-
slot_bound = sigc::bind< -1, sigc::reference_wrapper<Param> >(slot_full, sigc::ref(param));
55+
// slot_bound = sigc::bind(slot_full, std::ref(param));
56+
slot_bound = sigc::bind< -1, std::reference_wrapper<Param> >(slot_full, std::ref(param));
5757

5858
result_stream << "Calling slot when param exists:";
5959
slot_bound();

tests/test_bind_return.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ int main(int argc, char* argv[])
5252
// references.
5353
std::string str("guest book");
5454
// A convoluted way to do
55-
// sigc::bind_return(foo(), sigc::ref(str))(6) = "main";
56-
sigc::bind_return<sigc::reference_wrapper<std::string> >(foo(), sigc::ref(str))(6) = "main";
55+
// sigc::bind_return(foo(), std::ref(str))(6) = "main";
56+
sigc::bind_return<std::reference_wrapper<std::string> >(foo(), std::ref(str))(6) = "main";
5757
result_stream << str;
5858
util->check_result(result_stream, "foo(int 6) main");
5959

@@ -67,7 +67,7 @@ int main(int argc, char* argv[])
6767
sigc::slot<bar, int> sl;
6868
{
6969
bar choco(-1);
70-
sl = sigc::bind_return(foo(),sigc::ref(choco));
70+
sl = sigc::bind_return(foo(),std::ref(choco));
7171
result_stream << sl(7);
7272
util->check_result(result_stream, "foo(int 7) -1");
7373
} // auto-disconnect

tests/test_copy_invalid_slot.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ int main(int argc, char* argv[])
3030
util->check_result(result_stream, "sigc::trackable instance at " + pointer_stream.str());
3131
pointer_stream.str("");
3232

33-
sigc::slot<void> foo = sigc::bind(sigc::ptr_fun(Foo), sigc::ref(*t));
33+
sigc::slot<void> foo = sigc::bind(sigc::ptr_fun(Foo), std::ref(*t));
3434
foo();
3535
util->check_result(result_stream, "Foo(x)");
3636

tests/test_cpp11_lambda.cc

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,9 @@ int main(int argc, char* argv[])
182182
result_stream << ([] (int x) -> int { return ++x * 2; }(a_outer)) << " " << a_outer;
183183
util->check_result(result_stream, "4 1");
184184

185-
// gcc can't compile libsigc++ lambda expressions with sigc::ref() parameters.
185+
// gcc can't compile libsigc++ lambda expressions with std::ref() parameters.
186186
// See https://bugzilla.gnome.org/show_bug.cgi?id=669128
187-
// std::cout << "((++_1)*2)(ref(a)): " << ((++_1)*2)(sigc::ref(a));
187+
// std::cout << "((++_1)*2)(ref(a)): " << ((++_1)*2)(std::ref(a));
188188
// std::cout << "; a: " << a << std::endl;
189189
result_stream << ([] (std::reference_wrapper<int> x) -> int { return ++x * 2; }(std::ref(a_outer)));
190190
result_stream << " " << a_outer;
@@ -199,7 +199,7 @@ int main(int argc, char* argv[])
199199
result_stream << " " << a_outer;
200200
util->check_result(result_stream, "8 4");
201201

202-
// std::cout << "((--(*(&_1)))*2)(ref(a)): " << ((--(*(&_1)))*2)(sigc::ref(a));
202+
// std::cout << "((--(*(&_1)))*2)(ref(a)): " << ((--(*(&_1)))*2)(std::ref(a));
203203
// std::cout << "; a: " << a << std::endl;
204204
result_stream << ([] (std::reference_wrapper<int> x) -> int { return --(*(&x)) * 2; }(std::ref(a_outer)));
205205
result_stream << " " << a_outer;
@@ -241,15 +241,15 @@ int main(int argc, char* argv[])
241241
// - var() is used to create a lambda that holds a reference and is interchangable with ref() in lambda operator expressions
242242
// - cannot use std::endl without much hackery because it is defined as a template function
243243
// - cannot use "\n" without var() because arrays cannot be copied
244-
// (sigc::ref(std::cout) << sigc::constant(1) << sigc::var("\n"))();
244+
// (std::ref(std::cout) << sigc::constant(1) << sigc::var("\n"))();
245245
[](){ result_stream << 1 << "\n"; }();
246246
util->check_result(result_stream, "1\n");
247247

248-
//(sigc::ref(std::cout) << _1 << std::string("\n"))("hello world");
248+
//(std::ref(std::cout) << _1 << std::string("\n"))("hello world");
249249
[](const char* a){ result_stream << a << std::string("\n"); }("hello world");
250250
util->check_result(result_stream, "hello world\n");
251251

252-
//(sigc::ref(std::cout) << sigc::static_cast_<int>(_1) << std::string("\n"))(1.234);
252+
//(std::ref(std::cout) << sigc::static_cast_<int>(_1) << std::string("\n"))(1.234);
253253
[](double a){ result_stream << static_cast<int>(a) << std::string("\n"); }(1.234);
254254
util->check_result(result_stream, "1\n");
255255

@@ -269,7 +269,7 @@ int main(int argc, char* argv[])
269269
sigc::slot<void, std::ostringstream&> sl1;
270270
{
271271
book guest_book("karl");
272-
//sl1 = (sigc::var(std::cout) << sigc::ref(guest_book) << sigc::var("\n"));
272+
//sl1 = (sigc::var(std::cout) << std::ref(guest_book) << sigc::var("\n"));
273273
// sl1 = [&guest_book](std::ostringstream& stream){ stream << guest_book << "\n"; }; // no auto-disconnect
274274
sl1 = sigc::track_obj([&guest_book](std::ostringstream& stream){ stream << guest_book << "\n"; }, guest_book);
275275
sl1(result_stream);
@@ -290,7 +290,7 @@ int main(int argc, char* argv[])
290290
result_stream << std::bind(&foo, std::placeholders::_2, std::placeholders::_1)(1, 2);
291291
util->check_result(result_stream, "foo(int 2, int 1) 9");
292292

293-
//std::cout << (sigc::group(sigc::mem_fun(&bar::test), _1, _2, _3)) (sigc::ref(the_bar), 1, 2) << std::endl;
293+
//std::cout << (sigc::group(sigc::mem_fun(&bar::test), _1, _2, _3)) (std::ref(the_bar), 1, 2) << std::endl;
294294
// std::ref(the_bar) is not necessary. It can make the call ambiguous.
295295
// Even without std::ref() the_bar is not copied.
296296
result_stream << std::bind(std::mem_fn(&bar::test), std::placeholders::_1,
@@ -320,7 +320,7 @@ int main(int argc, char* argv[])
320320
sigc::slot<void> sl2;
321321
{
322322
book guest_book("karl");
323-
//sl2 = sigc::group(&egon, sigc::ref(guest_book));
323+
//sl2 = sigc::group(&egon, std::ref(guest_book));
324324
// sl2 = [&guest_book] () { egon(guest_book); }; // no auto-disconnect
325325
// sl2 = std::bind(&egon, std::ref(guest_book)); // does not compile (gcc 4.6.3)
326326
sl2 = sigc::track_obj([&guest_book] () { egon(guest_book); }, guest_book);
@@ -339,7 +339,7 @@ int main(int argc, char* argv[])
339339
// More auto-disconnect
340340
{
341341
book guest_book("charlie");
342-
//sl2 = sigc::group(&egon, sigc::ref(guest_book));
342+
//sl2 = sigc::group(&egon, std::ref(guest_book));
343343
// sl2 = std::bind(&egon, std::ref(guest_book)); // does not compile (gcc 4.6.3)
344344
auto fn2 = std::bind(&egon, std::ref(guest_book));
345345
//sl2 = fn2; // no auto-disconnect
@@ -469,9 +469,9 @@ int main(int argc, char* argv[])
469469
{
470470
int some_int = 0;
471471
sigc::signal<void> some_signal;
472-
//some_signal.connect(sigc::group(&foo,sigc::ref(some_int)));
472+
//some_signal.connect(sigc::group(&foo,std::ref(some_int)));
473473
//some_signal.connect(std::bind(&foo_group3, std::ref(some_int))); // does not compile (gcc 4.6.3)
474-
//some_signal.connect(sigc::bind(&foo_group3, sigc::ref(some_int))); // compiles, but we prefer std::bind() or C++11 lambda
474+
//some_signal.connect(sigc::bind(&foo_group3, std::ref(some_int))); // compiles, but we prefer std::bind() or C++11 lambda
475475
some_signal.connect([&some_int](){ foo_group3(some_int); });
476476
some_signal.emit();
477477
result_stream << " " << some_int;
@@ -483,10 +483,10 @@ int main(int argc, char* argv[])
483483
sigc::signal<void> some_signal;
484484
{
485485
bar_group4 some_bar;
486-
//some_signal.connect(sigc::group(&foo,sigc::ref(some_bar)));
486+
//some_signal.connect(sigc::group(&foo,std::ref(some_bar)));
487487
// disconnected automatically if some_bar goes out of scope
488488
//some_signal.connect([&some_bar](){ foo_group4(some_bar); }); // no auto-disconnect
489-
//some_signal.connect(sigc::bind(&foo_group4, sigc::ref(some_bar))); // auto-disconnects, but we prefer C++11 lambda
489+
//some_signal.connect(sigc::bind(&foo_group4, std::ref(some_bar))); // auto-disconnects, but we prefer C++11 lambda
490490
some_signal.connect(sigc::track_obj([&some_bar](){ foo_group4(some_bar); }, some_bar));
491491
some_signal.emit();
492492
util->check_result(result_stream, "foo_group4(bar_group4&)");

tests/test_functor_trait.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,15 @@ int main(int argc, char* argv[])
8383
int k = 3;
8484
A a;
8585
result_stream << "hit all targets: ";
86-
sigc::visit_each(print(), sigc::compose(sigc::bind(sigc::ptr_fun3(&foo), sigc::ref(a), i), sigc::ptr_fun1(&bar)));
86+
sigc::visit_each(print(), sigc::compose(sigc::bind(sigc::ptr_fun3(&foo), std::ref(a), i), sigc::ptr_fun1(&bar)));
8787
util->check_result(result_stream, "hit all targets: other trackable int: 1 other ");
8888

8989
result_stream << "hit all ints: ";
90-
sigc::visit_each_type<int>(print(), sigc::compose(sigc::bind(sigc::ptr_fun3(&foo), sigc::ref(a), j),sigc::ptr_fun1(&bar)));
90+
sigc::visit_each_type<int>(print(), sigc::compose(sigc::bind(sigc::ptr_fun3(&foo), std::ref(a), j),sigc::ptr_fun1(&bar)));
9191
util->check_result(result_stream, "hit all ints: int: 2 ");
9292

9393
result_stream << "hit all trackable: ";
94-
sigc::visit_each_type<trackable>(print(), sigc::compose(sigc::bind(sigc::ptr_fun3(&foo), sigc::ref(a), k),sigc::ptr_fun1(&bar)));
94+
sigc::visit_each_type<trackable>(print(), sigc::compose(sigc::bind(sigc::ptr_fun3(&foo), std::ref(a), k),sigc::ptr_fun1(&bar)));
9595
util->check_result(result_stream, "hit all trackable: trackable ");
9696

9797
return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;

tests/test_limit_reference.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ int main(int argc, char* argv[])
4545
util->check_result(result_stream, "method()");
4646

4747
auto param =
48-
sigc::bind(sigc::slot<void, Derived&>(), sigc::ref(*instance));
48+
sigc::bind(sigc::slot<void, Derived&>(), std::ref(*instance));
4949
param();
5050
util->check_result(result_stream, "");
5151

5252
auto ret =
53-
sigc::bind_return(sigc::slot<void>(), sigc::ref(*instance));
53+
sigc::bind_return(sigc::slot<void>(), std::ref(*instance));
5454
ret();
5555
util->check_result(result_stream, "");
5656

tests/test_track_obj.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,10 +202,10 @@ int main(int argc, char* argv[])
202202
sigc::signal<void> some_signal;
203203
{
204204
bar_group4 some_bar;
205-
//some_signal.connect(sigc::group(&foo,sigc::ref(some_bar)));
205+
//some_signal.connect(sigc::group(&foo,std::ref(some_bar)));
206206
// disconnected automatically if some_bar goes out of scope
207207
//some_signal.connect([&some_bar](){ foo_group4(some_bar); }); // no auto-disconnect
208-
//some_signal.connect(sigc::bind(&foo_group4, sigc::ref(some_bar))); // auto-disconnects, but we prefer C++11 lambda
208+
//some_signal.connect(sigc::bind(&foo_group4, std::ref(some_bar))); // auto-disconnects, but we prefer C++11 lambda
209209
some_signal.connect(sigc::track_obj([&some_bar](){ foo_group4(some_bar); }, some_bar));
210210
some_signal.emit();
211211
util->check_result(result_stream, "foo_group4(bar_group4&)");

0 commit comments

Comments
 (0)