Re: Template-Parameterized Variadic isInstaceOf

2015-08-08 Thread Nordlöw
On Friday, 7 August 2015 at 11:45:22 UTC, Nordlöw wrote: To implement a new trait isSortedRange(R, pred) needed for SortedRange specializations I need a variant of I've put all my progress into https://github.com/D-Programming-Language/phobos/pull/3534

Re: Template-Parameterized Variadic isInstaceOf

2015-08-07 Thread Tofu Ninja via Digitalmars-d-learn
On Friday, 7 August 2015 at 14:45:44 UTC, Nordlöw wrote: On Friday, 7 August 2015 at 14:30:55 UTC, Nordlöw wrote: Any suggestions on adding support for `binaryFun!pred` aswell? I cracked it. template isSortedRange(T, alias pred = "a < b") { import std.traits : TemplateArgsOf; static

Re: Template-Parameterized Variadic isInstaceOf

2015-08-07 Thread Nordlöw
On Friday, 7 August 2015 at 14:30:55 UTC, Nordlöw wrote: Any suggestions on adding support for `binaryFun!pred` aswell? I cracked it. template isSortedRange(T, alias pred = "a < b") { import std.traits : TemplateArgsOf; static if (TemplateArgsOf!T.length == 2) { import std

Re: Template-Parameterized Variadic isInstaceOf

2015-08-07 Thread Nordlöw
On Friday, 7 August 2015 at 14:13:24 UTC, Nordlöw wrote: How do check that the second template argument to the instance of SortedRange matches `pred`? Using TemplateArgsOf. I found a solution: template isSortedRange(T, alias pred = "a < b") { import std.traits : TemplateArgsOf; enum i

Re: Template-Parameterized Variadic isInstaceOf

2015-08-07 Thread Nordlöw
On Friday, 7 August 2015 at 11:45:22 UTC, Nordlöw wrote: Can somebody please explain and help out with variadic version of `isInstanceOf`? Here's a try at isSortedRange: enum bool isSortedRange(T, alias pred = "a < b") = is(T == SortedRange!(Args[0], pred), Args...); unittest { alias R

Re: Template-Parameterized Variadic isInstaceOf

2015-08-07 Thread Nordlöw
On Friday, 7 August 2015 at 11:45:22 UTC, Nordlöw wrote: Can somebody please explain and help out with variadic version of `isInstanceOf`? Here's a step forward: /** Returns true if $(D T) is an instance of the template $(D T) with template parameters $(D Ps). */ enum bool isInstanceOf

Re: Template-Parameterized Variadic isInstaceOf

2015-08-07 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 7 August 2015 at 11:45:22 UTC, Nordlöw wrote: To implement a new trait isSortedRange(R, pred) needed for SortedRange specializations I need a variant of enum bool isInstanceOf(alias S, T) = is(T == S!Args, Args...); that takes the `pred` argument aswell. But I have no cl

Template-Parameterized Variadic isInstaceOf

2015-08-07 Thread Nordlöw
To implement a new trait isSortedRange(R, pred) needed for SortedRange specializations I need a variant of enum bool isInstanceOf(alias S, T) = is(T == S!Args, Args...); that takes the `pred` argument aswell. But I have no clue what to do with enum bool isInstanceOf(alias S, T, T

Re: Template-Parameterized Variadic isInstaceOf

2015-08-07 Thread Nordlöw
On Friday, 7 August 2015 at 11:45:22 UTC, Nordlöw wrote: enum bool isInstanceOf(alias S, T, TParams) Correction: enum bool isInstanceOf(alias S, T, TParams...)