C++ Logo

sg7

Advanced search

Re: [SG7] Update: P1240R2 — Scalable Reflection

From: Peter Dimov <pdimov_at_[hidden]>
Date: Sat, 15 Jan 2022 20:39:39 +0200
Daveed Vandevoorde wrote:
> Hello reflecting friends,
>
> (And Happy New Year!)
>
> I’ve uploaded on the 2022 Teleconferences wiki for SG-7 an updated version
> of P1240 (which has also been submitted for the next mailing).
>
> Changes include:
> — The syntax agreements that SG-7 voted through P2320 (e.g., prefix ^
> instead of reflexpr(…) to create reflections)
> — The proposed metafunctions now use span and string_view instead
> of vector and string
> — Various corrections and clarifications based on reader feedback and
> implementation experience

I think that it might be worth discussing Matus's alternative representation
of reflections. Roughly, while P1240 has something equivalent to

struct info { uintptr_t id; };

Matus instead suggests (if I understand correctly)

template<uintptr_t id> struct info {};

This implies that one does

    constexpr info x = ^T;

under P1240 and

    constexpr auto x = ^T;

under the hypothetical alternative.

The arguments against this are (again IIUC) performance - the latter
causes much more template instantiations because functions are like

    consteval some_func( auto refl );

instead of

    consteval some_func( info refl );

However, there's a difference in usability, too. In the first case, one can
always splice [:refl:] inside some_func (because it's an instantiation context),
whereas in the second case, one cannot.

Received on 2022-01-15 18:39:40