I'm trying to figure out why the following fails to compile when I pass in the variable "a" as an lvalue to attach(), but compiles fine when I pass it in an rvalue, e.g. with std::move().
#include <cstdlib>
class Test
{
public:
Test() {}
~Test() {}
bool func(char c)
{
return true;
}
};
template <typename R, typename C, typename T1, typename... T2>
bool attach(C& obj,
R(C::*func)(T1,T2...), T1&& arg1, T2&&... args)
{
return true;
}
int main(int argc, char** argv)
{
Test test;
char a = 'a';
attach<bool,Test,char>(test, &Test::func, a);
return EXIT_SUCCESS;
}
Here, why isn't "a" deduced as an lvalue according to the template collapsing rules?
Aucun commentaire:
Enregistrer un commentaire