C++ Logo

sg7

Advanced search

Re: [SG7] Incomplete types

From: Hana Dusíková <hanicka_at_[hidden]>
Date: Mon, 2 Nov 2020 15:11:58 +0100
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


Received on 2020-11-02 08:12:05