functional: _Bind class function-call operator template has wrong return type default parameter
Jonathan Wakely
jwakely@redhat.com
Tue Dec 15 11:39:00 GMT 2015
On 15/12/15 09:50 +0200, Boris Zikeyev wrote:
>The _Bind class function-call operator looks something like this:
>template<typename... _Args, typename _Result
>= decltype( std::declval<_Functor>()(_Mu<_Bound_args>()(
>std::declval<_Bound_args&>(), std::declval<tuple<_Args...>&>() )... )
>)>
>_Result operator()(_Args&&... __args) { ... }
>The problem is that std::declval returns an rvalue reference, but the
>functor is invoked in an lvalue context. As a result, the following
>(valid) code will fail to compile:
>#include<functional>
>struct B {};
>struct C {};
>struct A {
>B operator()(int, double, char) & { return B(); }
>C operator()(int, double, char) && {return C(); }
>};
>int main() {
>A a;
>auto bound = std::bind(a, 5, 4.3, 'c');
>auto res = bound();
>}
Thanks for the report. Bugs should be reported to Bugzilla as
described at https://gcc.gnu.org/bugs/ so I've created
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68912 and will commit a
fix later today.
More information about the Libstdc++
mailing list