This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[c++0x patch] allow std::bind<void>


This patch fixes the included testcase, which failed in two ways.

Firstly, overload resolution for bind<void>(...) tries to match the
first overload of bind, causing an invalid instantiation in a context
where SFINAE doesn't apply, producing:
error: forming reference to void
Fixed by adding a valid specialisation so that overload resolution can proceed.

Secondly, if the bound function returns non-void we instantiate something like:

template <typename>
struct Bind_result {

    template<typename... Args>
        void
        operator()(Args... a)
        { return _M_fn(a); }  // error
};

which produces:
error: return-statement with a value, in function returning 'void'
Fixed by overloading the call functions and using SFINAE on
is_void<Res> to enable/disable overloads.

        * include/std/functional (bind): Avoid invalid instantiations
        for bind<void>.
        * testsuite/20_util/bind/conv_result.cc: New.

Tested x86_64/Linux.  I plan to commit this later today.

Attachment: bind_void.txt
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]