C++ Logo

std-discussion

Advanced search

Re: Question about name lookup and class member?

From: Edward Catmur <ecatmur_at_[hidden]>
Date: Sun, 6 Jun 2021 18:04:30 +0100
On Sun, 6 Jun 2021, 17:57 Eric Suen via Std-Discussion, <
std-discussion_at_[hidden]> wrote:

> The following code, how do parser know that V is template and B is not?
>

NSDMIs are evaluated in a complete-class context. This is one reason they
can't be `auto`.

struct A {
> int a = V<1>();
> bool b = B < 0;
>
> void print() {
> std::cout << a;
> }
>
> template<int v>
> static int V() {
> return v;
> }
>
> static int B;
> };
>
> int A::B = 1;
>
> int main() {
> A a;
> a.print();
> }
> --
> Std-Discussion mailing list
> Std-Discussion_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-discussion
>

Received on 2021-06-06 12:04:49