문제

What is the matter of the error, which produces the following code?

struct foo
{
    void call(void (foo::*ptr)()) &&
    {
        (*this.*ptr)();
    }
};

How to fix this error?

도움이 되었습니까?

해결책

Since the member pointer has the rvalue qualifier, the compiler must be told that *this is to be treated as an rvalue by using std::move on it:

(std::move(*this).*ptr)();
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top