C++ Logo

sg7

Advanced search

Re: [SG7] Incomplete types

From: Andrew Sutton <asutton.list_at_[hidden]>
Date: Mon, 2 Nov 2020 14:03:15 -0500
>
>
> Default member initializers are parsed in a complete-class-context",
> essentially meaning the parsing is delayed until the closing } of the class.
>
>
> Right, but Hana’s two examples aren’t in such contexts, and we permit them
> anyway. Lookup succeeds, but some operations (like offsetof) aren’t
> permitted.
>

Wow. I am not reading well today.

Adding consteval blocks to the complete-class-context might make lookups
> work in metaprograms, but that also breaks this very simple model.
>
>
> I don’t think we have to make consteval blocks part of the complete-class
> context of the enclosing class. Lookup already works. We just have to
> ensure that it is clear that some properties of nonstatic data members
> aren’t queryable. E.g.:
>
> struct S {
> int a;
> consteval {
> -> inject_useful_decl<typename(reflexpr(S::a))>(); // Okay.
> }
> consteval {
> -> inject_other<meta::offset_of(reflexpr(S::a))>(); // Error.
> }
> };
>
> A question we’d have to answer is whether a reflection of a nonstatic data
> member obtained while the class is still incomplete would remain valid
> after the class is completed, and, if so, whether the completeness would be
> reflected in that reflection (so that, e.g., querying the offset later on
> would work). IMO, the answer should be yes to both of those.
>

I must be forgetting where lookup fails, but we've definitely run into
issues requiring complete class types in *some* contexts. Wyatt can
probably answer that question better than I can at this point.

Received on 2020-11-02 13:03:27