@@ -21,7 +21,6 @@ Distributed under the Boost Software License, Version 1.0.
2121module std.numeric ;
2222
2323import std.complex ;
24- import std.exception ;
2524import std.math ;
2625import std.range.primitives ;
2726import std.traits ;
@@ -183,7 +182,7 @@ private:
183182
184183 // If on Linux or Mac, where 80-bit reals are padded, ignore the
185184 // padding.
186- import std.algorithm : min;
185+ import std.algorithm.comparison : min;
187186 CustomFloat! (CustomFloatParams! (min(F.sizeof* 8 , 80 ))) get ;
188187
189188 // Convert F to the correct binary type.
@@ -260,6 +259,7 @@ private:
260259 // Set the current value from signed exponent, normalized form
261260 void fromNormalized (T,U)(ref T sig, ref U exp)
262261 {
262+ import std.exception : enforce;
263263 auto shift = (T.sizeof* 8 ) - precision;
264264 if (exp == exp.max)
265265 {
@@ -495,6 +495,8 @@ public:
495495 if (__traits(compiles, cast (real )input))
496496 {
497497 import std.conv : text;
498+ import std.exception : enforce;
499+
498500 static if (staticIndexOf! (Unqual! F, float , double , real ) >= 0 )
499501 auto value = ToBinary! (Unqual! F)(input);
500502 else
@@ -1626,6 +1628,8 @@ CommonType!(ElementType!(Range1), ElementType!(Range2))
16261628euclideanDistance(Range1, Range2)(Range1 a, Range2 b)
16271629 if (isInputRange! (Range1) && isInputRange! (Range2))
16281630{
1631+ import std.exception : enforce;
1632+
16291633 enum bool haveLen = hasLength! (Range1) && hasLength! (Range2);
16301634 static if (haveLen) enforce(a.length == b.length);
16311635 Unqual! (typeof (return )) result = 0 ;
@@ -1643,6 +1647,8 @@ CommonType!(ElementType!(Range1), ElementType!(Range2))
16431647euclideanDistance(Range1, Range2, F)(Range1 a, Range2 b, F limit)
16441648 if (isInputRange! (Range1) && isInputRange! (Range2))
16451649{
1650+ import std.exception : enforce;
1651+
16461652 limit *= limit;
16471653 enum bool haveLen = hasLength! (Range1) && hasLength! (Range2);
16481654 static if (haveLen) enforce(a.length == b.length);
@@ -1686,6 +1692,8 @@ dotProduct(Range1, Range2)(Range1 a, Range2 b)
16861692 if (isInputRange! (Range1) && isInputRange! (Range2) &&
16871693 ! (isArray! (Range1) && isArray! (Range2)))
16881694{
1695+ import std.exception : enforce;
1696+
16891697 enum bool haveLen = hasLength! (Range1) && hasLength! (Range2);
16901698 static if (haveLen) enforce(a.length == b.length);
16911699 Unqual! (typeof (return )) result = 0 ;
@@ -1754,6 +1762,7 @@ dotProduct(F1, F2)(in F1[] avector, in F2[] bvector)
17541762@system unittest
17551763{
17561764 // @system due to dotProduct and assertCTFEable
1765+ import std.exception : assertCTFEable;
17571766 import std.meta : AliasSeq;
17581767 foreach (T; AliasSeq! (double , const double , immutable double ))
17591768 {
@@ -1781,6 +1790,8 @@ CommonType!(ElementType!(Range1), ElementType!(Range2))
17811790cosineSimilarity(Range1, Range2)(Range1 a, Range2 b)
17821791 if (isInputRange! (Range1) && isInputRange! (Range2))
17831792{
1793+ import std.exception : enforce;
1794+
17841795 enum bool haveLen = hasLength! (Range1) && hasLength! (Range2);
17851796 static if (haveLen) enforce(a.length == b.length);
17861797 Unqual! (typeof (return )) norma = 0 , normb = 0 , dotprod = 0 ;
@@ -1975,6 +1986,8 @@ CommonType!(ElementType!Range1, ElementType!Range2)
19751986kullbackLeiblerDivergence(Range1, Range2)(Range1 a, Range2 b)
19761987 if (isInputRange! (Range1) && isInputRange! (Range2))
19771988{
1989+ import std.exception : enforce;
1990+
19781991 enum bool haveLen = hasLength! (Range1) && hasLength! (Range2);
19791992 static if (haveLen) enforce(a.length == b.length);
19801993 Unqual! (typeof (return )) result = 0 ;
@@ -2021,6 +2034,8 @@ jensenShannonDivergence(Range1, Range2)(Range1 a, Range2 b)
20212034 if (isInputRange! Range1 && isInputRange! Range2 &&
20222035 is (CommonType! (ElementType! Range1, ElementType! Range2)))
20232036{
2037+ import std.exception : enforce;
2038+
20242039 enum bool haveLen = hasLength! (Range1) && hasLength! (Range2);
20252040 static if (haveLen) enforce(a.length == b.length);
20262041 Unqual! (typeof (return )) result = 0 ;
@@ -2049,6 +2064,8 @@ jensenShannonDivergence(Range1, Range2, F)(Range1 a, Range2 b, F limit)
20492064 is (typeof (CommonType! (ElementType! Range1, ElementType! Range2).init
20502065 >= F.init) : bool ))
20512066{
2067+ import std.exception : enforce;
2068+
20522069 enum bool haveLen = hasLength! (Range1) && hasLength! (Range2);
20532070 static if (haveLen) enforce(a.length == b.length);
20542071 Unqual! (typeof (return )) result = 0 ;
@@ -2162,7 +2179,8 @@ F gapWeightedSimilarity(alias comp = "a == b", R1, R2, F)(R1 s, R2 t, F lambda)
21622179 isRandomAccessRange! (R2 ) && hasLength! (R2 ))
21632180{
21642181 import std.functional : binaryFun;
2165- import std.algorithm : swap;
2182+ import std.algorithm.mutation : swap;
2183+ import std.exception : enforce;
21662184 import core.stdc.stdlib : malloc, free;
21672185
21682186 if (s.length < t.length) return gapWeightedSimilarity(t, s, lambda);
@@ -2301,6 +2319,7 @@ time and computes all matches of length 1.
23012319 */
23022320 this (Range s, Range t, F lambda)
23032321 {
2322+ import std.exception : enforce, errnoEnforce;
23042323 enforce(lambda > 0 );
23052324 this .gram = 0 ;
23062325 this .lambda = lambda;
@@ -2369,7 +2388,7 @@ time and computes all matches of length 1.
23692388 */
23702389 void popFront ()
23712390 {
2372- import std.algorithm : swap;
2391+ import std.algorithm.mutation : swap;
23732392
23742393 // This is a large source of optimization: if similarity at
23752394 // the gram-1 level was 0, then we can safely assume
@@ -2576,6 +2595,7 @@ T gcd(T)(T a, T b)
25762595 {
25772596 static if (T.min < 0 )
25782597 {
2598+ import std.exception : enforce;
25792599 enforce(a >= 0 && b >= 0 );
25802600 }
25812601 while (b)
@@ -2615,7 +2635,7 @@ private alias lookup_t = float;
26152635 */
26162636final class Fft
26172637{
2618- import std.algorithm : map;
2638+ import std.algorithm.iteration : map;
26192639 import core.bitop : bsf;
26202640 import std.array : uninitializedArray;
26212641
@@ -2625,6 +2645,7 @@ private:
26252645 void enforceSize (R)(R range) const
26262646 {
26272647 import std.conv : text;
2648+ import std.exception : enforce;
26282649 enforce(range.length <= size, text(
26292650 " FFT size mismatch. Expected " , size, " , got " , range.length));
26302651 }
@@ -2850,6 +2871,7 @@ private:
28502871 // to immutable.
28512872 public this (lookup_t[] memSpace) // Public b/c of bug 4636.
28522873 {
2874+ import std.exception : enforce;
28532875 immutable size = memSpace.length / 2 ;
28542876
28552877 /* Create a lookup table of all negative sine values at a resolution of
@@ -2964,6 +2986,7 @@ public:
29642986 void fft (Ret, R)(R range, Ret buf) const
29652987 if (isRandomAccessRange! Ret && isComplexLike! (ElementType! Ret) && hasSlicing! Ret)
29662988 {
2989+ import std.exception : enforce;
29672990 enforce(buf.length == range.length);
29682991 enforceSize(range);
29692992
0 commit comments