C ++: searching for a name in the definition of a static class variable in the initializer

I have a simple code:

#include <type_traits>

class A {
public:
    static int a;
};

void a() {}

int A::a = [](){static_assert(std::is_function<decltype(a)>::value,"'a' is not a function");return 777;}();

int main() {

    return 0;
}

At compile time (with g ++ 4.8.1 and clang 3.4), getting a static assert error about 'a' is not a function. But inside assert, in decltype I put 'a' (which is a function) not A :: a. Shouldnt component use function (a) instead of class member (A :: a)?

Can you give a link to the C ++ specification where this is explained?

+4
source share
2 answers

Ifnt component used function (a) instead of class member (A :: a)?

; , a .

++, ?

++ 11 3.3.7; :

, , , , ( )

+3

, A::a, - A.

+2

Source: https://habr.com/ru/post/1534428/


All Articles