C++ Logo

SG7

Advanced search

Subject: Re: P2320 implementation
From: Wyatt Childers (wchilders_at_[hidden])
Date: 2021-03-18 18:39:37


Hi Peter,

The expansion statement syntax was changed to "template for" (p1240 has
not yet received this update) e.g.

 Â Â Â  template for (constexpr auto x : m) {
 Â Â Â Â Â Â Â  char const * name = meta::name_of(x);
 Â Â Â  }

However, there seems to be a bug
<https://github.com/lock3/meta/issues/296> where the name_of call is not
immediate.

As for the range expansion, we do not currently have an implementation
for this, and are considering changes.

Best,

Wyatt

On 3/16/21 7:26 PM, Peter Dimov via SG7 wrote:
> Hana Dusíková wrote:
>> Hi,
>>
>> as some of you already asked me directly:
>>
>> https://github.com/lock3/meta/tree/paper/p2320 is current implementation
>> of P2320, you can also try it in the Compiler Explorer:
>>
>> https://cppx.godbolt.org/z/TfTTa9 (language: cppx, compiler: p2320 trunk)
>>
>> Thanks Andrew and Wyatt for awesome work! 🌷
> Ditto, and thanks Hana for the link.
>
> I've been trying to try things, and here's where I'm stuck at the moment:
> https://cppx.godbolt.org/z/T8f7eo
>
> #include <experimental/meta>
> namespace meta = std::experimental::meta;
>
> enum E
> {
> e1, e2
> };
>
> int main()
> {
> constexpr auto m = meta::members_of( ^E );
> for constexpr (auto x: m) { constexpr char const * name = meta::name_of( x ); }
> constexpr char const * names[] = { meta::name_of(...[:m:])... };
> }
>
> Neither the `for constexpr` loop, nor the range expansion below it compile. I'm
> obviously doing something wrong, but I don't know what - the `for constexp` loop
> is directly taken from the P1240 examples, and the expansion below it ought to
> work according to my reading of P2320.
>
> What's my mistake?
>



SG7 list run by sg7-owner@lists.isocpp.org

Older Archives on Google Groups