C++ Logo

std-discussion

Advanced search

Re: Question about name lookup and class member?

From: Christof Meerwald <cmeerw_at_[hidden]>
Date: Sun, 6 Jun 2021 20:44:46 +0200
On Mon, Jun 07, 2021 at 02:16:19AM +0800, Eric Suen via Std-Discussion wrote:
> > NSDMIs are evaluated in a complete-class context. This is one reason
> > they can't be `auto`.
> How do you get complete-class context when you unable to parse
>
> int a = V<1>();
>
> correctly?
>
> Look ahead for ';' if you encounter '=' in declarator?

Basically, yes - except that it is a bit more complicated. You have to
know that it's actually a default member initializer (and not just a
const static integral init).

BTW, default function arguments for member functions are even more
complex to handle as you have to look for a comma or closing
parenthesis, but the comma can, of course, just be a comma in a
template argument list, e.g.

  struct A
  {
    void foo(int i = B<1, int>::value);
  
    template<int I, typename T>
    struct B
    {
      static const int value = 2;
    };
  };


Christof

-- 
http://cmeerw.org                              sip:cmeerw at cmeerw.org
mailto:cmeerw at cmeerw.org                   xmpp:cmeerw at cmeerw.org

Received on 2021-06-06 13:45:00