Member function call in decltype

前端 未结 6 1062
北荒
北荒 2021-02-05 09:23

The following code:

struct A
{
    int f(int);
    auto g(int x) -> decltype(f(x));
};

Fails to compile with the error:

erro         


        
6条回答
  •  有刺的猬
    2021-02-05 09:41

    Here are the magic words:

    struct A
    {
        int f(int);
        auto g(int x) -> decltype((((A*)0) ->* &A::f)(x)) ;
    };
    

    Edit I see from Mikael Persson's answer that this is how it's done in boost.

提交回复
热议问题