C++ Logo

sg7

Advanced search

Re: [SG7] SG7 Digest, Vol 11, Issue 2

From: David Vandevoorde <daveed_at_[hidden]>
Date: Wed, 4 Nov 2020 11:05:25 -0500
> 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


Received on 2020-11-04 10:05:29