mardi 23 février 2016

std bind for overloaded template function

I'm new to c++, especially templates. I'm trying to use bind to an overloaded template function - the actual function is serial_port::set_option. For now i have reached the following form:

auto f = std::bind(static_cast<boost::system::error_code(serial_port::*)
(const SettableSerialPortOption&,boost::system::error_code&)>
(&serial_port::set_option),sp_ptr,_1,ec);

with sp_ptr defined as:

std::shared_ptr<serial_port> sp_ptr;

the overloaded method definition is:

template<
    typename SettableSerialPortOption>
boost::system::error_code set_option(
    const SettableSerialPortOption & option,
    boost::system::error_code & ec);

My intention is to get a call like:

f(boost::asio::serial_port::baud_rate(9600));

to work. I have no idea where to define the name SettableSerialPortOption. Can you provide some help on this? Thanks

Aucun commentaire:

Enregistrer un commentaire