Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it safe to use std::bind with boost::signals2?

Is it safe to use std::bind to pass a member function to boost::signals2::signal::connect()? In other words, is boost::bind and std::bind interchangeable?

It compiles with VC++ 2010 SP1, but the template code is way over my head and I'm afraid I might be venturing into undefined behaviour territory.

like image 913
links77 Avatar asked Oct 10 '11 07:10

links77


People also ask

What is the use of std :: bind?

std::bind is a Standard Function Objects that acts as a Functional Adaptor i.e. it takes a function as input and returns a new function Object as an output with with one or more of the arguments of passed function bound or rearranged.

What is the return type of std :: bind?

The return type of std::bind holds a member object of type std::decay<F>::type constructed from std::forward<F>(f), and one object per each of args... , of type std::decay<Arg_i>::type, similarly constructed from std::forward<Arg_i>(arg_i).


1 Answers

I'm not experienced in the subject by I would expect connect to take anything that implements a valid function call operator. It should be safe to call it with any function or function object that matches the signature, be it boost::bind, std::bind or anything else. Boost libraries are designed to be generic, so they usually don't go picking each others implementation details.

like image 77
K-ballo Avatar answered Nov 03 '22 20:11

K-ballo