Thoughts on versioning
Ali Çehreli
acehreli at yahoo.com
Tue Oct 26 05:59:44 UTC 2021
On 10/25/21 9:58 PM, zjh wrote:
> On Tuesday, 26 October 2021 at 01:19:29 UTC, Andrei Alexandrescu wrote:
>> Versioning Phobos would free us from maintaining backward
>
> can we improve this
> ```d
> if (isInputRange!(Range1) && isInputRange!(Range2))
> ```
> to:
> ```d
> if isallInputRange(Range1,Range2)
> ```
> ?
> `C++`'s `concept` is very grace.
>
>
Easy in D but the following otherwise-attractive-short-hand-method
imports symbols at module level (at least privately):
private import std.meta : allSatisfy;
private import std.range : isInputRange;
alias isallInputRange(T...) = allSatisfy!(isInputRange, T);
void foo(A, B)(A a, B b)
if (isallInputRange!(A, B)) {
}
unittest {
static assert ( __traits(compiles, foo([0], [0])));
static assert (!__traits(compiles, foo([0], 42)));
static assert (!__traits(compiles, foo(42, [0])));
}
void main() {
}
Ali
More information about the Digitalmars-d
mailing list