Skip to content

CWG3130 [expr.prim.id.general] Naming function members of anonymous unions after P2996 Reflection #802

@hubert-reinterpretcast

Description

@hubert-reinterpretcast

Full name of submitter (unless configured in github; will be published with the issue): Hubert Tong

Reference (section label): [expr.prim.id.general]

Link to reflector thread (if any): N/A

Issue description:

https://wg21.link/expr.prim.id.general#3 leaves the meaning of id-expression‌s that denote function members of namespace-scope anonymous unions in a black hole as the applicable bullet assumes that a member of an anonymous union variable is necessarily a data member.

Special member functions of an anonymous union type are observable via reflection, however, implementations are still behind (https://godbolt.org/z/T5GTqcx58):

#include <meta>
using namespace std::meta;

static union { int x; };

constexpr info anon_union = parent_of(^^x);
static_assert(is_type(anon_union));

using AnonUnion = [:anon_union:];
using AUOpAssignType = AnonUnion &(AnonUnion &&);
using AUOpAssignMPTy = AUOpAssignType AnonUnion::*;

namespace idexpr {
AUOpAssignMPTy aumemptr = &AnonUnion::operator=;
}

namespace extractcall {
constexpr info au_mem = members_of(anon_union, access_context::unchecked())[5];
//static_assert(0, display_string_of(au_mem));
auto aumemptr = extract<AUOpAssignMPTy>(au_mem);
}

Suggested resolution:

Scope the subject paragraph to apply only to id-expression‌s denoting data members.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions