Skip to content

Clarify the *two* ct foreach statements #4267

@crazymonkyyy

Description

@crazymonkyyy

If the aggregate expression is a sequence, the loop body is statically expanded once for each element. This is the same as Static Foreach on a sequence.
https://dlang.org/spec/statement.html#foreach_over_tuples

this is false, whats the actual difference, who knows, but there are differences

import std;
template Val(alias I){ enum val=I;}
void foo(T...)(){
    static foreach(A;T){
        static if(is(A==float)){ continue;}//error
        A.stringof.writeln;
}}
void bar(T...)(){
	foreach(A;T){
        static if(is(A==float)){ continue;}//works
        A.stringof.writeln;
}}
unittest{
    foo!(int,float,bool);
    bar!(int,float,bool);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions