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();
}