summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2019-02-04 10:49:12 +0100
committerEugen Wissner <belka@caraus.de>2019-02-04 10:49:12 +0100
commitbf197a6554b94b2607bdbb8cd7fa0edf10145340 (patch)
tree39f4e73c31f072e5f500de1ede6e3bff7a773807
parent7af5c3082094c5507a48f5957ef680d8448fbfc3 (diff)
downloadtanya-bf197a6554b94b2607bdbb8cd7fa0edf10145340.tar.gz
Deprecate put() as an OutputRange primitive
-rw-r--r--source/tanya/algorithm/mutation.d9
-rw-r--r--source/tanya/range/primitive.d39
2 files changed, 10 insertions, 38 deletions
diff --git a/source/tanya/algorithm/mutation.d b/source/tanya/algorithm/mutation.d
index 99b0eae..642da7e 100644
--- a/source/tanya/algorithm/mutation.d
+++ b/source/tanya/algorithm/mutation.d
@@ -389,12 +389,9 @@ do
static struct OutPutRange
{
int value;
- void put(int value) @nogc nothrow pure @safe
- in
- {
- assert(this.value == 0);
- }
- do
+
+ void opCall(int value) @nogc nothrow pure @safe
+ in (this.value == 0)
{
this.value = value;
}
diff --git a/source/tanya/range/primitive.d b/source/tanya/range/primitive.d
index 8cf45f2..c9473aa 100644
--- a/source/tanya/range/primitive.d
+++ b/source/tanya/range/primitive.d
@@ -5,7 +5,7 @@
/**
* This module defines primitives for working with ranges.
*
- * Copyright: Eugene Wissner 2017-2018.
+ * Copyright: Eugene Wissner 2017-2019.
* License: $(LINK2 https://www.mozilla.org/en-US/MPL/2.0/,
* Mozilla Public License, v. 2.0).
* Authors: $(LINK2 mailto:info@caraus.de, Eugene Wissner)
@@ -833,18 +833,19 @@ void put(R, E)(ref R range, auto ref E e)
static if (__traits(hasMember, R, "put")
&& is(typeof((R r, E e) => r.put(e))))
{
+ pragma(msg, "OutputRange.put()-primitive is deprecated. Define opCall() instead.");
range.put(e);
}
+ else static if (is(typeof((R r, E e) => r(e))))
+ {
+ range(e);
+ }
else static if (isInputRange!R
&& is(typeof((R r, E e) => r.front = e)))
{
range.front = e;
range.popFront();
}
- else static if (is(typeof((R r, E e) => r(e))))
- {
- range(e);
- }
else
{
static assert(false, R.stringof ~ " is not an output range for "
@@ -865,23 +866,6 @@ void put(R, E)(ref R range, auto ref E e)
///
@nogc nothrow pure @safe unittest
{
- static struct Put
- {
- int e;
-
- void put(int e)
- {
- this.e = e;
- }
- }
- Put p;
- put(p, 2);
- assert(p.e == 2);
-}
-
-///
-@nogc nothrow pure @safe unittest
-{
static struct OpCall
{
int e;
@@ -963,7 +947,7 @@ template isOutputRange(R, E)
{
static struct R1
{
- void put(int) @nogc nothrow pure @safe
+ void opCall(int) @nogc nothrow pure @safe
{
}
}
@@ -1002,17 +986,8 @@ template isOutputRange(R, E)
}
static assert(!isOutputRange!(R3, int));
- static struct R4
- {
- void opCall(int) @nogc nothrow pure @safe
- {
- }
- }
- static assert(isOutputRange!(R4, int));
-
static assert(isOutputRange!(R1, R3));
static assert(isOutputRange!(R2, R3));
- static assert(isOutputRange!(R4, R3));
}
/**