C++ Logo

SG7

Advanced search

Subject: Re: SG7 Digest, Vol 11, Issue 2
From: David Vandevoorde (daveed_at_[hidden])
Date: 2020-11-04 10:05:25


> On Nov 4, 2020, at 8:59 AM, Andrew Sutton via SG7 <sg7_at_[hidden]> wrote:
>
> Even if you declare a forward class D the error still persists...
>
> struct A2 {
> struct B {};
> struct D;
> consteval {
> -> fragment struct {
> B b = D(); //error
> B getB() { return D(); } //error
> };
> }
> struct D : B {};
> };
>
>
> Well, yeah. D hasn't been defined at the point it's used.

Hmm, that's an interesting case. One would expect that to work since doing the injection manually works:

        struct A2 {
          struct B {};
          struct D;
          B b = D(); // Okay.
          B getB() { return D(); } // Okay.
          struct D : B {};
        };

The way implementations handle that is by saving the tokens of the "complete-context component" for replay later on. Presumably, the fragment handling implementation doesn't do that, or it replays them before injection?

        Daveed



SG7 list run by sg7-owner@lists.isocpp.org

Older Archives on Google Groups