Search code examples
c++templatesboostboost-signals

How to get the return type of a boost::signal?


I use boost::signal with different function signatures and different combiners. In a class that looks like the one beyond I want to get the return of a certain signal declaration.

template<typename signal_type> class MyClass
{

    signal_type mSignal;

    signal_type::result_type getResult() { return mSignal(); }

}

But signal_type::result_type does not work. So is there a way to get the return type?


Solution

  • You need typename to use dependent types:

    typename signal_type::result_type getResult() { return mSignal(); }
    

    Dependent names (i.e. dependent on a template parameter) are assumed to

    • not name types unless prefixed with typename and to
    • not name templates unless immediately prefixed with template.