User talk:9rnsr/DIP: Template Parameter Constraint

From D Wiki
Jump to: navigation, search

(Page found through random Google search).

I really like the inline constraint feature:

auto foo(R if isInputRange)(R range);

Would love to see this giving cleaner errors.

Similar syntax could make the auto function parameter proposal more useful:

auto foo()(auto range if isInputRange);

Beside being easier to read (DRY), this disallows the user from supplying a type for R, and clearly documents the fact the user isn't expected to provide a type.

--NickTreleaven (talk) 15:03, 2 April 2016 (UTC)