Named template constraints
monarch_dodra via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Apr 22 08:36:07 PDT 2014
On Tuesday, 22 April 2014 at 15:30:36 UTC, Steven Schveighoffer
wrote:
> On Tue, 22 Apr 2014 11:15:14 -0400, monarch_dodra
> <monarchdodra at gmail.com> wrote:
>
>> On Tuesday, 22 April 2014 at 15:06:34 UTC, Steven
>> Schveighoffer wrote:
>>> Note, is the r2 = R.init needed? Not sure.
>>
>> Yes: It R2 has no default init, or is an immutable, then that
>> line will fail to compile.
>
> I don't believe it's possible to have no 'init'.
>
> I think the reason it says '= R.init' is for ranges that have
> @disable this().
Yes, that's what I meant by "no default init". Guess I got my
terms wrong. Sorry.
> Also, an immutable can be initialized that way:
>
> immutable int[] = int[].init;
Isn't that exactly "R.init" ?
> Of course, it wouldn't pass the rest of isInputRange.
>
> -Steve
In this particular case, probably not (except for, maybe
"repeat"?) In any case, it's become the "generic" way of
initializing a generic type.
More information about the Digitalmars-d-learn
mailing list