From e68fcc3a381228a05641f699d1c624766521e7c0 Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Sat, 29 Sep 2018 09:00:43 +0200 Subject: [PATCH] Remove code deprecated in 0.11.2 and earlier - conv.to!String - meta.metafunction.Tuple - range.adapter.take - range.adapter.takeExactly - range.primitive: put()-ting input range into an output one --- source/tanya/conv.d | 7 - source/tanya/meta/metafunction.d | 12 -- source/tanya/range/adapter.d | 247 ------------------------------- source/tanya/range/primitive.d | 32 ++-- 4 files changed, 17 insertions(+), 281 deletions(-) diff --git a/source/tanya/conv.d b/source/tanya/conv.d index bce5401..8eeb250 100644 --- a/source/tanya/conv.d +++ b/source/tanya/conv.d @@ -856,13 +856,6 @@ if (is(Unqual!From == bool) && isNumeric!To && !is(Unqual!To == Unqual!From)) assert(false.to!int == 0); } -deprecated("Use tanya.format.format instead") -To to(To, From)(auto ref From from) -if (is(Unqual!To == String)) -{ - return format!"{}"(from); -} - /** * Converts a stringish range to an integral value. * diff --git a/source/tanya/meta/metafunction.d b/source/tanya/meta/metafunction.d index 2599402..eff3ca0 100644 --- a/source/tanya/meta/metafunction.d +++ b/source/tanya/meta/metafunction.d @@ -238,18 +238,6 @@ struct Pack(Args...) alias Seq this; } -deprecated("Use Pack instead") -struct Tuple(Args...) -{ - /// Elements in this tuple as $(D_PSYMBOL AliasSeq). - alias Seq = Args; - - /// The length of the tuple. - enum size_t length = Args.length; - - alias Seq this; -} - /// @nogc nothrow pure @safe unittest { diff --git a/source/tanya/range/adapter.d b/source/tanya/range/adapter.d index 6951b33..ec2e5d9 100644 --- a/source/tanya/range/adapter.d +++ b/source/tanya/range/adapter.d @@ -5,12 +5,6 @@ /** * Range adapters. * - * A range adapter wraps another range and modifies the way, how the original - * range is iterated, or the order in which its elements are accessed. - * - * All adapters are lazy algorithms, they request the next element of the - * adapted range on demand. - * * Copyright: Eugene Wissner 2018. * License: $(LINK2 https://www.mozilla.org/en-US/MPL/2.0/, * Mozilla Public License, v. 2.0). @@ -18,245 +12,4 @@ * Source: $(LINK2 https://github.com/caraus-ecms/tanya/blob/master/source/tanya/range/adapter.d, * tanya/range/adapter.d) */ -deprecated("Use tanya.algorithm.iteration instead") module tanya.range.adapter; - -import tanya.algorithm.mutation; -import tanya.math; -import tanya.range.primitive; - -private mixin template Take(R, bool exactly) -{ - private R source; - size_t length_; - - @disable this(); - - private this(R source, size_t length) - { - this.source = source; - static if (!exactly && hasLength!R) - { - this.length_ = min(source.length, length); - } - else - { - this.length_ = length; - } - } - - @property auto ref front() - in - { - assert(!empty); - } - do - { - return this.source.front; - } - - void popFront() - in - { - assert(!empty); - } - do - { - this.source.popFront(); - --this.length_; - } - - @property bool empty() - { - static if (exactly || isInfinite!R) - { - return length == 0; - } - else - { - return length == 0 || this.source.empty; - } - } - - @property size_t length() - { - return this.length_; - } - - static if (hasAssignableElements!R) - { - @property void front(ref ElementType!R value) - in - { - assert(!empty); - } - do - { - this.source.front = value; - } - - @property void front(ElementType!R value) - in - { - assert(!empty); - } - do - { - this.source.front = move(value); - } - } - - static if (isForwardRange!R) - { - typeof(this) save() - { - return typeof(this)(this.source.save(), length); - } - } - static if (isRandomAccessRange!R) - { - @property auto ref back() - in - { - assert(!empty); - } - do - { - return this.source[this.length - 1]; - } - - void popBack() - in - { - assert(!empty); - } - do - { - --this.length_; - } - - auto ref opIndex(size_t i) - in - { - assert(i < length); - } - do - { - return this.source[i]; - } - - static if (hasAssignableElements!R) - { - @property void back(ref ElementType!R value) - in - { - assert(!empty); - } - do - { - this.source[length - 1] = value; - } - - @property void back(ElementType!R value) - in - { - assert(!empty); - } - do - { - this.source[length - 1] = move(value); - } - - void opIndexAssign(ref ElementType!R value, size_t i) - in - { - assert(i < length); - } - do - { - this.source[i] = value; - } - - void opIndexAssign(ElementType!R value, size_t i) - in - { - assert(i < length); - } - do - { - this.source[i] = move(value); - } - } - } - static if (hasSlicing!R) - { - auto opSlice(size_t i, size_t j) - in - { - assert(i <= j); - assert(j <= length); - } - do - { - return take(this.source[i .. j], length); - } - } -} - -/** - * Takes $(D_PARAM n) elements from $(D_PARAM range). - * - * If $(D_PARAM range) doesn't have $(D_PARAM n) elements, the resulting range - * spans all elements of $(D_PARAM range). - * - * $(D_PSYMBOL take) is particulary useful with infinite ranges. You can take - ` $(B n) elements from such range and pass the result to an algorithm which - * expects a finit range. - * - * Params: - * R = Type of the adapted range. - * range = The range to take the elements from. - * n = The number of elements to take. - * - * Returns: A range containing maximum $(D_PARAM n) first elements of - * $(D_PARAM range). - * - * See_Also: $(D_PSYMBOL takeExactly). - */ -auto take(R)(R range, size_t n) -if (isInputRange!R) -{ - struct Take - { - mixin .Take!(R, false); - } - return Take(range, n); -} - -/** - * Takes exactly $(D_PARAM n) elements from $(D_PARAM range). - * - * $(D_PARAM range) must have at least $(D_PARAM n) elements. - * - * $(D_PSYMBOL takeExactly) is particulary useful with infinite ranges. You can - ` take $(B n) elements from such range and pass the result to an algorithm - * which expects a finit range. - * - * Params: - * R = Type of the adapted range. - * range = The range to take the elements from. - * n = The number of elements to take. - * - * Returns: A range containing $(D_PARAM n) first elements of $(D_PARAM range). - * - * See_Also: $(D_PSYMBOL take). - */ -auto takeExactly(R)(R range, size_t n) -if (isInputRange!R) -{ - struct TakeExactly - { - mixin Take!(R, true); - } - return TakeExactly(range, n); -} diff --git a/source/tanya/range/primitive.d b/source/tanya/range/primitive.d index 1b3b96b..7495d65 100644 --- a/source/tanya/range/primitive.d +++ b/source/tanya/range/primitive.d @@ -813,17 +813,28 @@ template isRandomAccessRange(R) /** * Puts $(D_PARAM e) into the $(D_PARAM range). * - * $(D_PSYMBOL R) should be an output range for $(D_PARAM E). - * - * $(D_PARAM range) is advanced after putting an element into it if all of the - * following conditions are met: + * $(D_PSYMBOL R) should be an output range for $(D_PARAM E). It doesn't mean + * that everything $(D_PARAM range) is an output range for can be put into it, + * but only if one of the following conditions is met: * * $(OL - * $(LI $(D_PSYMBOL R) is an input range) - * $(LI $(D_PSYMBOL R) doesn't define a `put`-method) + * $(LI $(D_PARAM R) defines a `put`-method for $(D_PARAM E)) * $(LI $(D_PARAM e) can be assigned to $(D_INLINECODE range.front)) + * $(LI $(D_PARAM e) can be put into $(D_PARAM range) using + * $(D_INLINECODE range(e)) + * ) * ) * + * The method to put $(D_PARAM e) into $(D_PARAM range) is chosen based on the + * order specified above. + * + * If $(D_PARAM E) is an input range and $(D_PARAM R) is an output range for + * its elements as well, use $(D_PSYMBOL tanya.algorithm.mutation.copy) + * instead. + * + * $(D_PARAM range) is advanced after putting an element into it if it is an + * input range that doesn't define a `put`-method. + * * Params: * R = Target range type. * E = Source element type. @@ -849,15 +860,6 @@ void put(R, E)(ref R range, auto ref E e) { range(e); } - else static if (isInputRange!E) - { - pragma(msg, "Putting an input range into an output range is " - ~ "deprecated. Use tanya.algorithm.mutation.copy instead"); - for (; !e.empty; e.popFront()) - { - put(range, e.front); - } - } else { static assert(false, R.stringof ~ " is not an output range for "