Compile-time fold expression vs recursive template

Nick Treleaven nick at geany.org
Fri Jun 19 16:55:27 UTC 2020


On Sunday, 14 June 2020 at 12:01:51 UTC, Manu wrote:
> On Sun, Jun 14, 2020 at 9:50 PM Nick Treleaven via 
> Digitalmars-d < digitalmars-d at puremagic.com> wrote:
>> Manu did propose a follow up to that would support a very 
>> basic fold expression, but it seems to be limited to using an 
>> operator between element expressions (no `static if`):
>>
>> >> Static reduce would allow `...` as an argument to a BinOp
>> >> Ie; `Tup + ...` would expand `Tup[0] + Tup[1] + Tup[2] + 
>> >> ...`
>> >> You could do `is(FindType == Tup) || ...`, and it would
>> >> evaluate true if
>> >> FindType exists in Tup, with no junk template 
>> >> instantiations!
>>
>> https://forum.dlang.org/post/mailman.2786.1587566241.31109.digitalmars-d@puremagic.com
>>
> It's implemented in my branch too if you wanna try it out!

https://github.com/TurkeyMan/dmd/commit/e150fa03521e1d5d12c77477c6dbcb46c9292fac

Haven't tried it, but it doesn't seem to be able to help with 
recursive templates much. It can do std.meta.anySatisfy and 
allSatisfy, but probably can't do much other folding of sequences 
that don't contain values.


More information about the Digitalmars-d mailing list