Idiomatic way to process const/immutable arrays as ranges

Steven Schveighoffer schveiguy at yahoo.com
Mon Feb 11 11:52:51 PST 2013


On Mon, 11 Feb 2013 13:59:41 -0500, Dicebot <m.strashun at gmail.com> wrote:

> Ye, looks like this is the root of problem, I tweaked at a bit and have  
> come to the same conclusion :( Sad, I really hoped I simply have  
> overlooked some common idiom.

This is a bug, joinImpl compiles with the given type, it's just join that  
doesn't.

Note that I performed this change to the template constraint on join:

if(isInputRange!RoR &&
        (isInputRange!(ElementType!RoR) ||  
isDynamicArray!(ElementType!RoR)) &&
        isForwardRange!R &&
        is(Unqual!(ElementType!(ElementType!RoR)) ==  
Unqual!(ElementType!R)))

Note the isInputRange || isDynamicArray part.

This check was already present on joinImpl.

With that change, then you can compile my original suggestion, or my later  
suggestion.

-Steve


More information about the Digitalmars-d-learn mailing list