C++ Logo

SG7

Advanced search

Subject: Re: Incomplete types
From: Hana Dusíková (hanicka_at_[hidden])
Date: 2020-11-02 08:11:58


This seems counterintuitive to me. I consider `sizeof` and `decltype` a poor version of a reflection and you can do this:

struct X {
int a;
static constexpr unsigned size = sizeof(X::a);
using type = decltype(X::a);
};

https://compiler-explorer.com/z/9f7WKn <https://compiler-explorer.com/z/9f7WKn>

Even when the type is not yet complete. I personally think we should support such cases.

Hana

> On 2. 11. 2020, at 15:05, Andrew Sutton via SG7 <sg7_at_[hidden]> wrote:
>
> However, you cannot use lookup in the sense of [basic.lookup]. This should fail:
>
> struct X {
> int a;
> consteval {
> auto info = reflexpr(X::a); // error: X is incomplete.
> }
> };
>
> Andrew



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

Older Archives on Google Groups