Discussion on static reflection syntax in C++

Stefan Koch uplink.coder at googlemail.com
Tue Feb 23 16:31:49 UTC 2021


On Tuesday, 23 February 2021 at 16:10:26 UTC, Paul Backus wrote:
> On Tuesday, 23 February 2021 at 15:49:14 UTC, Stefan Koch wrote:
>> [...]
>
> My gut feeling is that it would not be too difficult to 
> understand in practice, but yes, it would require 
> special-casing.
>
>> [...]
>
> Actually, now that I think of it, wouldn't the existing CTFE 
> semantics prevent you from doing this anyway?
>
> enum __struct s = someTypeFunction();
> auto modify(ref __struct s) { ... }
> enum result = modify(s); // Error: can't modify rvalue
>
> Or if you tried to do it inside a type function:
>
> auto someTypeFunction(...) {
>     __struct s = ...;
>     alias Before = mixin(s); // Error: can't read `s` at 
> compile time
>     modify(s);
> }

... yes you have a point there.

... perhaps I am worrying too much.


More information about the Digitalmars-d mailing list