C++ Logo

std-proposals

Advanced search

Re: Meta types

From: Jake Arkinstall <jake.arkinstall_at_[hidden]>
Date: Fri, 7 Feb 2020 18:43:42 +0000
On Fri, 7 Feb 2020, 18:12 Михаил Найденов, <mihailnajdenov_at_[hidden]> wrote:

>
>
> On Fri, Feb 7, 2020 at 7:08 PM Lee Howes <xrikcus_at_[hidden]> wrote:
>
>> Well the idea would be that you could unroll it too:
>> for co_await(auto [key, value] : dictionary) {
>> foo(key, value);
>> }
>> (I forget what we intended for for co_await syntax, but it's not in there
>> yet anyway so let's go with it)
>>
>> The code would end up instantiating foo over all the key/value type
>> combinations. The coroutine callback logic for dictionary iteration would
>> yield each key/value pair by callback directly without any variant involved.
>>
>> This is all speculation though, because actually implementing this and
>> convincing people that the reader will not be confused is still a bit of a
>> step.
>>
>
> This is template for, I believe.
>

For the case of iterating over a static dictionary, template for would do
well.

It doesn't, however, solve the issue of iterating over types yielded based
on runtime values, such as a sequence of events generated by an input
string. It would instead require the sequence of types to be known at
compile time. A template for in this context would allow branching to
different instantiation of the for block depending on the type generated on
each iteration.

>

Received on 2020-02-07 12:46:30