On Thursday, 9 March 2017 at 20:54:23 UTC, Nick Sabalausky (Abscissa) wrote:
On 03/08/2017 04:34 PM, H. S. Teoh via Digitalmars-d wrote:
        auto parseFile(Slice)(Slice input)
                if (isRandomAccessRange!Slice && hasSlicing!Slice &&
                    is(ElementType!Slice : ubyte))
        {
                ... // use nice input[x .. y] syntax, yay!
                return result;
        }


Wishlist for D3: Some brilliant form of sugar for declaring a function that takes a range.

auto parseFile()(auto input if isRandomAccessRangeOf!ubyte && hasSlicing) {

My spin on an inline parameter constraint idea by Kenji (his doesn't use auto and also has more concept-like sugar):

https://wiki.dlang.org/User:9rnsr/DIP:_Template_Parameter_Constraint

As mentioned in the link, inline constraints can help make more specific error messages when constraints fail.

Reply via email to