Clang:如何用std :: function包装一个cv限定的成员函数?

时间:2015-11-21 01:46:38

标签: c++ c++11 g++ clang++

我在使用Clang编译以下代码时遇到问题:

#include <functional>

struct C {
    void m() const {}
};

int main() {
    C c;

    std::function<void(C*)> f1 = &C::m;
    f1(&c);

    std::function<void(C&)> f2 = &C::m;
    f2(c);

    std::function<void(C)> f3 = &C::m;
    f3(c);
}

报告的错误很长,可以看到here

GCC能够编译它。 如果删除了const限定符,则代码将在GCC和Clang上成功编译。

我使用的版本是:GCC 4.8.4,Clang 3.6.0。

0 个答案:

没有答案