bloomberg / clang-p2996

Experimental clang support for WG21 P2996 (Reflection).
https://github.com/bloomberg/clang-p2996/tree/p2996/P2996.md
51 stars 8 forks source link

Destructurable and iterable expansion statements #53

Open katzdm opened 3 months ago

katzdm commented 3 months ago

Scaffolding for expansion statements (as per P1306 can be enabled with -fexpansion-statements, but so far only support for expansion-init-lists has been implemented. We need to also support expansion over destructurable objects (e.g., structs) and over "constexpr ranges" (e.g., over vectors) - the later is especially important for improving the ergonomics of P2996.

Expansion over destructurable objects shouldn't be too bad, though it might involve some light surgery on the code for structured bindings.

Expansion over constexpr ranges is trickier, as earlier versions of the proposal assumed support for non-transient constexpr allocation as a dependency. We've tried to carve out an exceptional case from [expr.const] for P1306R2, but implementation could be tricky - need to think of some way to "extend the lifetime" of an object constructed by the constant evaluator. Some rough ideas, but not too sure yet.