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]

Re: functional: _Bind class function-call operator template has wrong return typeâ default parameterâ


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.


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