diff --git a/std/algorithm/comparison.d b/std/algorithm/comparison.d index 4467334d3..7e44331f7 100644 --- a/std/algorithm/comparison.d +++ b/std/algorithm/comparison.d @@ -84,7 +84,7 @@ range. */ uint among(alias pred = (a, b) => a == b, Value, Values...) (Value value, Values values) - if (Values.length != 0) +if (Values.length != 0) { foreach (uint i, ref v; values) { @@ -96,7 +96,7 @@ uint among(alias pred = (a, b) => a == b, Value, Values...) /// Ditto template among(values...) - if (isExpressionTuple!values) +if (isExpressionTuple!values) { uint among(Value)(Value value) if (!is(CommonType!(Value, values) == void)) @@ -617,7 +617,8 @@ if (isInputRange!R1 && isInputRange!R2 && !(isSomeString!R1 && isSomeString!R2)) } /// ditto -int cmp(alias pred = "a < b", R1, R2)(R1 r1, R2 r2) if (isSomeString!R1 && isSomeString!R2) +int cmp(alias pred = "a < b", R1, R2)(R1 r1, R2 r2) +if (isSomeString!R1 && isSomeString!R2) { import core.stdc.string : memcmp; import std.utf : decode; @@ -958,7 +959,7 @@ range of range (of range...) comparisons. // MaxType private template MaxType(T...) - if (T.length >= 1) +if (T.length >= 1) { static if (T.length == 1) { @@ -1200,7 +1201,7 @@ Does not allocate GC memory. */ size_t levenshteinDistance(alias equals = (a,b) => a == b, Range1, Range2) (Range1 s, Range2 t) - if (isForwardRange!(Range1) && isForwardRange!(Range2)) +if (isForwardRange!(Range1) && isForwardRange!(Range2)) { alias eq = binaryFun!(equals); @@ -1271,7 +1272,7 @@ size_t levenshteinDistance(alias equals = (a,b) => a == b, Range1, Range2) /// ditto size_t levenshteinDistance(alias equals = (a,b) => a == b, Range1, Range2) (auto ref Range1 s, auto ref Range2 t) - if (isConvertibleToString!Range1 || isConvertibleToString!Range2) +if (isConvertibleToString!Range1 || isConvertibleToString!Range2) { import std.meta : staticMap; alias Types = staticMap!(convertToString, Range1, Range2); @@ -1312,7 +1313,7 @@ Allocates GC memory for the returned EditOp[] array. Tuple!(size_t, EditOp[]) levenshteinDistanceAndPath(alias equals = (a,b) => a == b, Range1, Range2) (Range1 s, Range2 t) - if (isForwardRange!(Range1) && isForwardRange!(Range2)) +if (isForwardRange!(Range1) && isForwardRange!(Range2)) { Levenshtein!(Range1, binaryFun!(equals)) lev; auto d = lev.distanceWithPath(s, t); @@ -1344,7 +1345,7 @@ levenshteinDistanceAndPath(alias equals = (a,b) => a == b, Range1, Range2) Tuple!(size_t, EditOp[]) levenshteinDistanceAndPath(alias equals = (a,b) => a == b, Range1, Range2) (auto ref Range1 s, auto ref Range2 t) - if (isConvertibleToString!Range1 || isConvertibleToString!Range2) +if (isConvertibleToString!Range1 || isConvertibleToString!Range2) { import std.meta : staticMap; alias Types = staticMap!(convertToString, Range1, Range2); @@ -1375,7 +1376,7 @@ See_Also: $(REF maxElement, std,algorithm,searching) */ MaxType!T max(T...)(T args) - if (T.length >= 2) +if (T.length >= 2) { //Get "a" static if (T.length <= 2) @@ -1448,7 +1449,7 @@ MaxType!T max(T...)(T args) // MinType private template MinType(T...) - if (T.length >= 1) +if (T.length >= 1) { static if (T.length == 1) { @@ -1489,7 +1490,7 @@ See_Also: $(REF minElement, std,algorithm,searching) */ MinType!T min(T...)(T args) - if (T.length >= 2) +if (T.length >= 2) { //Get "a" static if (T.length <= 2) @@ -1560,7 +1561,7 @@ See_Also: */ Tuple!(Range1, Range2) mismatch(alias pred = "a == b", Range1, Range2)(Range1 r1, Range2 r2) - if (isInputRange!(Range1) && isInputRange!(Range2)) +if (isInputRange!(Range1) && isInputRange!(Range2)) { for (; !r1.empty && !r2.empty; r1.popFront(), r2.popFront()) { @@ -1745,10 +1746,10 @@ Returns: $(D true) if both ranges have the same length, $(D false) otherwise. */ bool isSameLength(Range1, Range2)(Range1 r1, Range2 r2) - if (isInputRange!Range1 && - isInputRange!Range2 && - !isInfinite!Range1 && - !isInfinite!Range2) +if (isInputRange!Range1 && + isInputRange!Range2 && + !isInfinite!Range1 && + !isInfinite!Range2) { static if (hasLength!(Range1) && hasLength!(Range2)) { @@ -1889,11 +1890,11 @@ Returns: bool isPermutation(AllocateGC allocate_gc, Range1, Range2) (Range1 r1, Range2 r2) - if (allocate_gc == Yes.allocateGC && - isForwardRange!Range1 && - isForwardRange!Range2 && - !isInfinite!Range1 && - !isInfinite!Range2) +if (allocate_gc == Yes.allocateGC && + isForwardRange!Range1 && + isForwardRange!Range2 && + !isInfinite!Range1 && + !isInfinite!Range2) { alias E1 = Unqual!(ElementType!Range1); alias E2 = Unqual!(ElementType!Range2); @@ -1937,11 +1938,11 @@ bool isPermutation(AllocateGC allocate_gc, Range1, Range2) /// ditto bool isPermutation(alias pred = "a == b", Range1, Range2) (Range1 r1, Range2 r2) - if (is(typeof(binaryFun!(pred))) && - isForwardRange!Range1 && - isForwardRange!Range2 && - !isInfinite!Range1 && - !isInfinite!Range2) +if (is(typeof(binaryFun!(pred))) && + isForwardRange!Range1 && + isForwardRange!Range2 && + !isInfinite!Range1 && + !isInfinite!Range2) { import std.algorithm.searching : count; @@ -2093,9 +2094,9 @@ Returns: The _first argument that passes the test `pred`. */ CommonType!(T, Ts) either(alias pred = a => a, T, Ts...)(T first, lazy Ts alternatives) - if (alternatives.length >= 1 && - !is(CommonType!(T, Ts) == void) && - allSatisfy!(ifTestable, T, Ts)) +if (alternatives.length >= 1 && + !is(CommonType!(T, Ts) == void) && + allSatisfy!(ifTestable, T, Ts)) { alias predFun = unaryFun!pred; diff --git a/std/algorithm/iteration.d b/std/algorithm/iteration.d index 6985ebd9e..a6d9eceb6 100644 --- a/std/algorithm/iteration.d +++ b/std/algorithm/iteration.d @@ -70,7 +70,8 @@ import std.functional; // : unaryFun, binaryFun; import std.range.primitives; import std.traits; -private template aggregate(fun...) if (fun.length >= 1) +private template aggregate(fun...) +if (fun.length >= 1) { /* --Intentionally not ddoc-- * Aggregates elements in each subrange of the given range of ranges using @@ -453,7 +454,8 @@ Returns: See_Also: $(HTTP en.wikipedia.org/wiki/Map_(higher-order_function), Map (higher-order function)) */ -template map(fun...) if (fun.length >= 1) +template map(fun...) +if (fun.length >= 1) { auto map(Range)(Range r) if (isInputRange!(Unqual!Range)) { @@ -1084,7 +1086,8 @@ Returns: See_Also: $(HTTP en.wikipedia.org/wiki/Filter_(higher-order_function), Filter (higher-order function)) */ -template filter(alias predicate) if (is(typeof(unaryFun!predicate))) +template filter(alias predicate) +if (is(typeof(unaryFun!predicate))) { auto filter(Range)(Range range) if (isInputRange!(Unqual!Range)) { @@ -1394,7 +1397,8 @@ Group!(pred, Range) group(alias pred = "a == b", Range)(Range r) } /// ditto -struct Group(alias pred, R) if (isInputRange!R) +struct Group(alias pred, R) +if (isInputRange!R) { import std.typecons : Rebindable, tuple, Tuple; @@ -1542,7 +1546,7 @@ struct Group(alias pred, R) if (isInputRange!R) // Used by implementation of chunkBy for non-forward input ranges. private struct ChunkByChunkImpl(alias pred, Range) - if (isInputRange!Range && !isForwardRange!Range) +if (isInputRange!Range && !isForwardRange!Range) { alias fun = binaryFun!pred; @@ -1581,7 +1585,7 @@ private template ChunkByImplIsUnary(alias pred, Range) // Implementation of chunkBy for non-forward input ranges. private struct ChunkByImpl(alias pred, Range) - if (isInputRange!Range && !isForwardRange!Range) +if (isInputRange!Range && !isForwardRange!Range) { enum bool isUnary = ChunkByImplIsUnary!(pred, Range); @@ -1645,7 +1649,7 @@ private struct ChunkByImpl(alias pred, Range) // Single-pass implementation of chunkBy for forward ranges. private struct ChunkByImpl(alias pred, Range) - if (isForwardRange!Range) +if (isForwardRange!Range) { import std.typecons : RefCounted; @@ -1861,7 +1865,7 @@ private struct ChunkByImpl(alias pred, Range) * element. */ auto chunkBy(alias pred, Range)(Range r) - if (isInputRange!Range) +if (isInputRange!Range) { return ChunkByImpl!(pred, Range)(r); } @@ -2699,7 +2703,8 @@ See_Also: $(LREF sum) is similar to $(D reduce!((a, b) => a + b)) that offers pairwise summing of floating point numbers. +/ -template reduce(fun...) if (fun.length >= 1) +template reduce(fun...) +if (fun.length >= 1) { import std.meta : staticMap; @@ -3068,7 +3073,8 @@ The number of seeds must be correspondingly increased. //http://forum.dlang.org/post/oghtttkopzjshsuflelk@forum.dlang.org //Seed is tuple of const. static auto minmaxElement(alias F = min, alias G = max, R)(in R range) - @safe pure nothrow if (isInputRange!R) + @safe pure nothrow + if (isInputRange!R) { return reduce!(F, G)(tuple(ElementType!R.max, ElementType!R.min), range); @@ -3149,7 +3155,8 @@ See_Also: This is functionally equivalent to $(LREF reduce) with the argument order reversed, and without the need to use $(LREF tuple) for multiple seeds. +/ -template fold(fun...) if (fun.length >= 1) +template fold(fun...) +if (fun.length >= 1) { auto fold(R, S...)(R r, S seed) { @@ -3522,7 +3529,8 @@ The number of seeds must be correspondingly increased. //Seed is tuple of const. static auto minmaxElement(alias F = min, alias G = max, R)(in R range) - @safe pure nothrow if (isInputRange!R) + @safe pure nothrow + if (isInputRange!R) { return range.cumulativeFold!(F, G)(tuple(ElementType!R.max, ElementType!R.min)); } @@ -5121,14 +5129,14 @@ See_Also: $(REF nextPermutation, std,algorithm,sorting). */ Permutations!Range permutations(Range)(Range r) - if (isRandomAccessRange!Range && hasLength!Range) +if (isRandomAccessRange!Range && hasLength!Range) { return typeof(return)(r); } /// ditto struct Permutations(Range) - if (isRandomAccessRange!Range && hasLength!Range) +if (isRandomAccessRange!Range && hasLength!Range) { private size_t[] _indices, _state; private Range _r; diff --git a/std/algorithm/mutation.d b/std/algorithm/mutation.d index 573bb1378..c2986d44d 100644 --- a/std/algorithm/mutation.d +++ b/std/algorithm/mutation.d @@ -114,7 +114,7 @@ See_Also: $(HTTP sgi.com/tech/stl/_rotate.html, STL's rotate) */ size_t bringToFront(InputRange, ForwardRange)(InputRange front, ForwardRange back) - if (isInputRange!InputRange && isForwardRange!ForwardRange) +if (isInputRange!InputRange && isForwardRange!ForwardRange) { import std.string : representation; @@ -139,7 +139,7 @@ size_t bringToFront(InputRange, ForwardRange)(InputRange front, ForwardRange bac } private size_t bringToFrontImpl(InputRange, ForwardRange)(InputRange front, ForwardRange back) - if (isInputRange!InputRange && isForwardRange!ForwardRange) +if (isInputRange!InputRange && isForwardRange!ForwardRange) { import std.range : take, Take; import std.array : sameHead; @@ -363,7 +363,7 @@ See_Also: $(HTTP sgi.com/tech/stl/_copy.html, STL's _copy) */ TargetRange copy(SourceRange, TargetRange)(SourceRange source, TargetRange target) - if (areCopyCompatibleArrays!(SourceRange, TargetRange)) +if (areCopyCompatibleArrays!(SourceRange, TargetRange)) { const tlen = target.length; const slen = source.length; @@ -392,9 +392,9 @@ TargetRange copy(SourceRange, TargetRange)(SourceRange source, TargetRange targe /// ditto TargetRange copy(SourceRange, TargetRange)(SourceRange source, TargetRange target) - if (!areCopyCompatibleArrays!(SourceRange, TargetRange) && - isInputRange!SourceRange && - isOutputRange!(TargetRange, ElementType!SourceRange)) +if (!areCopyCompatibleArrays!(SourceRange, TargetRange) && + isInputRange!SourceRange && + isOutputRange!(TargetRange, ElementType!SourceRange)) { // Specialize for 2 random access ranges. // Typically 2 random access ranges are faster iterated by common @@ -541,7 +541,7 @@ See_Also: $(LREF initializeAll) */ void fill(Range, Value)(Range range, Value value) - if (isInputRange!Range && is(typeof(range.front = value))) +if (isInputRange!Range && is(typeof(range.front = value))) { alias T = ElementType!Range; @@ -652,10 +652,10 @@ Params: representing the _fill pattern. */ void fill(InputRange, ForwardRange)(InputRange range, ForwardRange filler) - if (isInputRange!InputRange - && (isForwardRange!ForwardRange - || (isInputRange!ForwardRange && isInfinite!ForwardRange)) - && is(typeof(InputRange.init.front = ForwardRange.init.front))) +if (isInputRange!InputRange + && (isForwardRange!ForwardRange + || (isInputRange!ForwardRange && isInfinite!ForwardRange)) + && is(typeof(InputRange.init.front = ForwardRange.init.front))) { static if (isInfinite!ForwardRange) { @@ -776,7 +776,7 @@ See_Also: $(LREF uninitializeFill) */ void initializeAll(Range)(Range range) - if (isInputRange!Range && hasLvalueElements!Range && hasAssignableElements!Range) +if (isInputRange!Range && hasLvalueElements!Range && hasAssignableElements!Range) { import core.stdc.string : memset, memcpy; import std.traits : hasElaborateAssign, isDynamicArray; @@ -825,7 +825,7 @@ void initializeAll(Range)(Range range) /// ditto void initializeAll(Range)(Range range) - if (is(Range == char[]) || is(Range == wchar[])) +if (is(Range == char[]) || is(Range == wchar[])) { alias T = ElementEncodingType!Range; range[] = T.init; @@ -2226,21 +2226,21 @@ if (isNarrowString!(Char[]) && !is(Char == const) && !is(Char == immutable)) a Range with all of range except element at the start and end */ Range strip(Range, E)(Range range, E element) - if (isBidirectionalRange!Range && is(typeof(range.front == element) : bool)) +if (isBidirectionalRange!Range && is(typeof(range.front == element) : bool)) { return range.stripLeft(element).stripRight(element); } /// ditto Range strip(alias pred, Range)(Range range) - if (isBidirectionalRange!Range && is(typeof(pred(range.back)) : bool)) +if (isBidirectionalRange!Range && is(typeof(pred(range.back)) : bool)) { return range.stripLeft!pred().stripRight!pred(); } /// ditto Range stripLeft(Range, E)(Range range, E element) - if (isInputRange!Range && is(typeof(range.front == element) : bool)) +if (isInputRange!Range && is(typeof(range.front == element) : bool)) { import std.algorithm.searching : find; return find!((auto ref a) => a != element)(range); @@ -2248,7 +2248,7 @@ Range stripLeft(Range, E)(Range range, E element) /// ditto Range stripLeft(alias pred, Range)(Range range) - if (isInputRange!Range && is(typeof(pred(range.front)) : bool)) +if (isInputRange!Range && is(typeof(pred(range.front)) : bool)) { import std.algorithm.searching : find; import std.functional : not; @@ -2258,7 +2258,7 @@ Range stripLeft(alias pred, Range)(Range range) /// ditto Range stripRight(Range, E)(Range range, E element) - if (isBidirectionalRange!Range && is(typeof(range.back == element) : bool)) +if (isBidirectionalRange!Range && is(typeof(range.back == element) : bool)) { for (; !range.empty; range.popBack()) { @@ -2270,7 +2270,7 @@ Range stripRight(Range, E)(Range range, E element) /// ditto Range stripRight(alias pred, Range)(Range range) - if (isBidirectionalRange!Range && is(typeof(pred(range.back)) : bool)) +if (isBidirectionalRange!Range && is(typeof(pred(range.back)) : bool)) { for (; !range.empty; range.popBack()) { @@ -2572,7 +2572,7 @@ unittest /// ditto void swap(T)(ref T lhs, ref T rhs) - if (is(typeof(lhs.proxySwap(rhs)))) +if (is(typeof(lhs.proxySwap(rhs)))) { lhs.proxySwap(rhs); } @@ -2694,7 +2694,7 @@ pure @safe nothrow unittest } private void swapFront(R1, R2)(R1 r1, R2 r2) - if (isInputRange!R1 && isInputRange!R2) +if (isInputRange!R1 && isInputRange!R2) { static if (is(typeof(swap(r1.front, r2.front)))) { @@ -2727,8 +2727,8 @@ Returns: */ Tuple!(InputRange1, InputRange2) swapRanges(InputRange1, InputRange2)(InputRange1 r1, InputRange2 r2) - if (hasSwappableElements!InputRange1 && hasSwappableElements!InputRange2 - && is(ElementType!InputRange1 == ElementType!InputRange2)) +if (hasSwappableElements!InputRange1 && hasSwappableElements!InputRange2 + && is(ElementType!InputRange1 == ElementType!InputRange2)) { for (; !r1.empty && !r2.empty; r1.popFront(), r2.popFront()) { @@ -2768,7 +2768,7 @@ See_Also: $(LREF initializeAll) */ void uninitializedFill(Range, Value)(Range range, Value value) - if (isInputRange!Range && hasLvalueElements!Range && is(typeof(range.front = value))) +if (isInputRange!Range && hasLvalueElements!Range && is(typeof(range.front = value))) { import std.traits : hasElaborateAssign; diff --git a/std/algorithm/searching.d b/std/algorithm/searching.d index 32c764e35..c3ce4417f 100644 --- a/std/algorithm/searching.d +++ b/std/algorithm/searching.d @@ -381,7 +381,8 @@ public: /// Ditto BoyerMooreFinder!(binaryFun!(pred), Range) boyerMooreFinder (alias pred = "a == b", Range) -(Range needle) if ((isRandomAccessRange!(Range) && hasSlicing!Range) || isSomeString!Range) +(Range needle) +if ((isRandomAccessRange!(Range) && hasSlicing!Range) || isSomeString!Range) { return typeof(return)(needle); } @@ -615,8 +616,8 @@ Returns: The number of positions in the `haystack` for which `pred` returned true. */ size_t count(alias pred = "a == b", Range, E)(Range haystack, E needle) - if (isInputRange!Range && !isInfinite!Range && - is(typeof(binaryFun!pred(haystack.front, needle)) : bool)) +if (isInputRange!Range && !isInfinite!Range && + is(typeof(binaryFun!pred(haystack.front, needle)) : bool)) { bool pred2(ElementType!Range a) { return binaryFun!pred(a, needle); } return count!pred2(haystack); @@ -672,9 +673,9 @@ size_t count(alias pred = "a == b", Range, E)(Range haystack, E needle) /// Ditto size_t count(alias pred = "a == b", R1, R2)(R1 haystack, R2 needle) - if (isForwardRange!R1 && !isInfinite!R1 && - isForwardRange!R2 && - is(typeof(binaryFun!pred(haystack.front, needle.front)) : bool)) +if (isForwardRange!R1 && !isInfinite!R1 && + isForwardRange!R2 && + is(typeof(binaryFun!pred(haystack.front, needle.front)) : bool)) { assert(!needle.empty, "Cannot count occurrences of an empty range"); @@ -696,8 +697,8 @@ size_t count(alias pred = "a == b", R1, R2)(R1 haystack, R2 needle) /// Ditto size_t count(alias pred = "true", R)(R haystack) - if (isInputRange!R && !isInfinite!R && - is(typeof(unaryFun!pred(haystack.front)) : bool)) +if (isInputRange!R && !isInfinite!R && + is(typeof(unaryFun!pred(haystack.front)) : bool)) { size_t result; alias T = ElementType!R; //For narrow strings forces dchar iteration @@ -745,12 +746,12 @@ size_t count(alias pred = "true", R)(R haystack) See_Also: $(REF indexOf, std,string) +/ ptrdiff_t countUntil(alias pred = "a == b", R, Rs...)(R haystack, Rs needles) - if (isForwardRange!R - && Rs.length > 0 - && isForwardRange!(Rs[0]) == isInputRange!(Rs[0]) - && is(typeof(startsWith!pred(haystack, needles[0]))) - && (Rs.length == 1 - || is(typeof(countUntil!pred(haystack, needles[1 .. $]))))) +if (isForwardRange!R + && Rs.length > 0 + && isForwardRange!(Rs[0]) == isInputRange!(Rs[0]) + && is(typeof(startsWith!pred(haystack, needles[0]))) + && (Rs.length == 1 + || is(typeof(countUntil!pred(haystack, needles[1 .. $]))))) { typeof(return) result; @@ -833,8 +834,8 @@ ptrdiff_t countUntil(alias pred = "a == b", R, Rs...)(R haystack, Rs needles) /// ditto ptrdiff_t countUntil(alias pred = "a == b", R, N)(R haystack, N needle) - if (isInputRange!R && - is(typeof(binaryFun!pred(haystack.front, needle)) : bool)) +if (isInputRange!R && + is(typeof(binaryFun!pred(haystack.front, needle)) : bool)) { bool pred2(ElementType!R a) { return binaryFun!pred(a, needle); } return countUntil!pred2(haystack); @@ -903,8 +904,8 @@ ptrdiff_t countUntil(alias pred = "a == b", R, N)(R haystack, N needle) before $(D pred(haystack.front)) is $(D true). +/ ptrdiff_t countUntil(alias pred, R)(R haystack) - if (isInputRange!R && - is(typeof(unaryFun!pred(haystack.front)) : bool)) +if (isInputRange!R && + is(typeof(unaryFun!pred(haystack.front)) : bool)) { typeof(return) i; static if (isRandomAccessRange!R) @@ -1117,8 +1118,8 @@ if (isBidirectionalRange!R && /// Ditto bool endsWith(alias pred, R)(R doesThisEnd) - if (isInputRange!R && - ifTestable!(typeof(doesThisEnd.front), unaryFun!pred)) +if (isInputRange!R && + ifTestable!(typeof(doesThisEnd.front), unaryFun!pred)) { return !doesThisEnd.empty && unaryFun!pred(doesThisEnd.back); } @@ -1252,7 +1253,7 @@ Returns: The extreme value according to `map` and `selector` of the passed-in values. */ private auto extremum(alias map = "a", alias selector = "a < b", Range)(Range r) - if (isInputRange!Range && !isInfinite!Range) +if (isInputRange!Range && !isInfinite!Range) in { assert(!r.empty, "r is an empty range"); @@ -1269,8 +1270,8 @@ body private auto extremum(alias map = "a", alias selector = "a < b", Range, RangeElementType = ElementType!Range) (Range r, RangeElementType seedElement) - if (isInputRange!Range && !isInfinite!Range && - !is(CommonType!(ElementType!Range, RangeElementType) == void)) +if (isInputRange!Range && !isInfinite!Range && + !is(CommonType!(ElementType!Range, RangeElementType) == void)) { alias mapFun = unaryFun!map; alias selectorFun = binaryFun!selector; @@ -2509,7 +2510,7 @@ See_Also: $(HTTP sgi.com/tech/stl/adjacent_find.html, STL's adjacent_find) */ Range findAdjacent(alias pred = "a == b", Range)(Range r) - if (isForwardRange!(Range)) +if (isForwardRange!(Range)) { auto ahead = r.save; if (!ahead.empty) @@ -2587,7 +2588,7 @@ See_Also: */ InputRange findAmong(alias pred = "a == b", InputRange, ForwardRange)( InputRange seq, ForwardRange choices) - if (isInputRange!InputRange && isForwardRange!ForwardRange) +if (isInputRange!InputRange && isForwardRange!ForwardRange) { for (; !seq.empty && find!pred(choices, seq.front).empty; seq.popFront()) { @@ -3283,7 +3284,7 @@ See_Also: $(REF min, std,algorithm,comparison) */ auto minElement(alias map = "a", Range)(Range r) - if (isInputRange!Range && !isInfinite!Range) +if (isInputRange!Range && !isInfinite!Range) { return extremum!map(r); } @@ -3291,8 +3292,8 @@ auto minElement(alias map = "a", Range)(Range r) /// ditto auto minElement(alias map = "a", Range, RangeElementType = ElementType!Range) (Range r, RangeElementType seed) - if (isInputRange!Range && !isInfinite!Range && - !is(CommonType!(ElementType!Range, RangeElementType) == void)) +if (isInputRange!Range && !isInfinite!Range && + !is(CommonType!(ElementType!Range, RangeElementType) == void)) { return extremum!map(r, seed); } @@ -3375,8 +3376,8 @@ See_Also: $(REF max, std,algorithm,comparison) */ auto maxElement(alias map = "a", Range)(Range r) - if (isInputRange!Range && !isInfinite!Range && - !is(CommonType!(ElementType!Range, RangeElementType) == void)) +if (isInputRange!Range && !isInfinite!Range && + !is(CommonType!(ElementType!Range, RangeElementType) == void)) { return extremum!(map, "a > b")(r); } @@ -3384,7 +3385,7 @@ auto maxElement(alias map = "a", Range)(Range r) /// ditto auto maxElement(alias map = "a", Range, RangeElementType = ElementType!Range) (Range r, RangeElementType seed) - if (isInputRange!Range && !isInfinite!Range) +if (isInputRange!Range && !isInfinite!Range) { return extremum!(map, "a > b")(r, seed); } @@ -3477,8 +3478,8 @@ smallest (respectively largest) element and with the same ending as `range`. */ Range minPos(alias pred = "a < b", Range)(Range range) - if (isForwardRange!Range && !isInfinite!Range && - is(typeof(binaryFun!pred(range.front, range.front)))) +if (isForwardRange!Range && !isInfinite!Range && + is(typeof(binaryFun!pred(range.front, range.front)))) { static if (hasSlicing!Range && isRandomAccessRange!Range && hasLength!Range) { @@ -3593,8 +3594,8 @@ See_Also: $(REF min, std,algorithm,comparison), $(LREF minCount), $(LREF minElement), $(LREF minPos) */ sizediff_t minIndex(alias pred = "a < b", Range)(Range range) - if (isForwardRange!Range && !isInfinite!Range && - is(typeof(binaryFun!pred(range.front, range.front)))) +if (isForwardRange!Range && !isInfinite!Range && + is(typeof(binaryFun!pred(range.front, range.front)))) { if (range.empty) return -1; @@ -3711,8 +3712,8 @@ See_Also: $(REF max, std,algorithm,comparison), $(LREF maxCount), $(LREF maxElement), $(LREF maxPos) */ sizediff_t maxIndex(alias pred = "a < b", Range)(Range range) - if (isInputRange!Range && !isInfinite!Range && - is(typeof(binaryFun!pred(range.front, range.front)))) +if (isInputRange!Range && !isInfinite!Range && + is(typeof(binaryFun!pred(range.front, range.front)))) { return range.minIndex!((a, b) => binaryFun!pred(b, a)); } @@ -3800,8 +3801,8 @@ advanced to the point past this segment; otherwise false, and $(D r1) is left in its original position. */ bool skipOver(R1, R2)(ref R1 r1, R2 r2) - if (isForwardRange!R1 && isInputRange!R2 - && is(typeof(r1.front == r2.front))) +if (isForwardRange!R1 && isInputRange!R2 + && is(typeof(r1.front == r2.front))) { static if (is(typeof(r1[0 .. $] == r2) : bool) && is(typeof(r2.length > r1.length) : bool) @@ -3822,9 +3823,9 @@ bool skipOver(R1, R2)(ref R1 r1, R2 r2) /// Ditto bool skipOver(alias pred, R1, R2)(ref R1 r1, R2 r2) - if (is(typeof(binaryFun!pred(r1.front, r2.front))) && - isForwardRange!R1 && - isInputRange!R2) +if (is(typeof(binaryFun!pred(r1.front, r2.front))) && + isForwardRange!R1 && + isInputRange!R2) { static if (hasLength!R1 && hasLength!R2) { @@ -3880,14 +3881,14 @@ predicate, and the range has been advanced by one element; otherwise false, and the range is left untouched. */ bool skipOver(R, E)(ref R r, E e) - if (isInputRange!R && is(typeof(r.front == e) : bool)) +if (isInputRange!R && is(typeof(r.front == e) : bool)) { return skipOver!((a, b) => a == b)(r, e); } /// Ditto bool skipOver(alias pred, R, E)(ref R r, E e) - if (is(typeof(binaryFun!pred(r.front, e))) && isInputRange!R) +if (is(typeof(binaryFun!pred(r.front, e))) && isInputRange!R) { if (r.empty || !binaryFun!pred(r.front, e)) return false; @@ -4094,8 +4095,8 @@ if (isInputRange!R1 && /// Ditto bool startsWith(alias pred = "a == b", R, E)(R doesThisStart, E withThis) - if (isInputRange!R && - is(typeof(binaryFun!pred(doesThisStart.front, withThis)) : bool)) +if (isInputRange!R && + is(typeof(binaryFun!pred(doesThisStart.front, withThis)) : bool)) { return doesThisStart.empty ? false @@ -4104,8 +4105,8 @@ bool startsWith(alias pred = "a == b", R, E)(R doesThisStart, E withThis) /// Ditto bool startsWith(alias pred, R)(R doesThisStart) - if (isInputRange!R && - ifTestable!(typeof(doesThisStart.front), unaryFun!pred)) +if (isInputRange!R && + ifTestable!(typeof(doesThisStart.front), unaryFun!pred)) { return !doesThisStart.empty && unaryFun!pred(doesThisStart.front); } @@ -4315,7 +4316,8 @@ until(alias pred, Range) } /// ditto -struct Until(alias pred, Range, Sentinel) if (isInputRange!Range) +struct Until(alias pred, Range, Sentinel) +if (isInputRange!Range) { private Range _input; static if (!is(Sentinel == void)) diff --git a/std/algorithm/setops.d b/std/algorithm/setops.d index 89b9a6db1..9f9c855dc 100644 --- a/std/algorithm/setops.d +++ b/std/algorithm/setops.d @@ -77,8 +77,8 @@ Returns: cartesian product of the given ranges. */ auto cartesianProduct(R1, R2)(R1 range1, R2 range2) - if (!allSatisfy!(isForwardRange, R1, R2) || - anySatisfy!(isInfinite, R1, R2)) +if (!allSatisfy!(isForwardRange, R1, R2) || + anySatisfy!(isInfinite, R1, R2)) { import std.algorithm.iteration : map, joiner; @@ -346,9 +346,9 @@ pure nothrow @safe @nogc unittest /// ditto auto cartesianProduct(RR...)(RR ranges) - if (ranges.length >= 2 && - allSatisfy!(isForwardRange, RR) && - !anySatisfy!(isInfinite, RR)) +if (ranges.length >= 2 && + allSatisfy!(isForwardRange, RR) && + !anySatisfy!(isInfinite, RR)) { // This overload uses a much less template-heavy implementation when // all ranges are finite forward ranges, which is the most common use @@ -443,8 +443,8 @@ auto cartesianProduct(RR...)(RR ranges) /// ditto auto cartesianProduct(R1, R2, RR...)(R1 range1, R2 range2, RR otherRanges) - if (!allSatisfy!(isForwardRange, R1, R2, RR) || - anySatisfy!(isInfinite, R1, R2, RR)) +if (!allSatisfy!(isForwardRange, R1, R2, RR) || + anySatisfy!(isInfinite, R1, R2, RR)) { /* We implement the n-ary cartesian product by recursively invoking the * binary cartesian product. To make the resulting range nicer, we denest @@ -879,7 +879,7 @@ Returns: See_also: $(LREF setSymmetricDifference) */ struct SetDifference(alias less = "a < b", R1, R2) - if (isInputRange!(R1) && isInputRange!(R2)) +if (isInputRange!(R1) && isInputRange!(R2)) { private: R1 r1; @@ -987,8 +987,8 @@ Returns: A range containing the intersection of the given ranges. */ struct SetIntersection(alias less = "a < b", Rs...) - if (Rs.length >= 2 && allSatisfy!(isInputRange, Rs) && - !is(CommonType!(staticMap!(ElementType, Rs)) == void)) +if (Rs.length >= 2 && allSatisfy!(isInputRange, Rs) && + !is(CommonType!(staticMap!(ElementType, Rs)) == void)) { private: Rs _input; @@ -1081,8 +1081,8 @@ public: /// Ditto SetIntersection!(less, Rs) setIntersection(alias less = "a < b", Rs...)(Rs ranges) - if (Rs.length >= 2 && allSatisfy!(isInputRange, Rs) && - !is(CommonType!(staticMap!(ElementType, Rs)) == void)) +if (Rs.length >= 2 && allSatisfy!(isInputRange, Rs) && + !is(CommonType!(staticMap!(ElementType, Rs)) == void)) { return typeof(return)(ranges); } @@ -1152,7 +1152,7 @@ Returns: See_also: $(LREF setDifference) */ struct SetSymmetricDifference(alias less = "a < b", R1, R2) - if (isInputRange!(R1) && isInputRange!(R2)) +if (isInputRange!(R1) && isInputRange!(R2)) { private: R1 r1; diff --git a/std/algorithm/sorting.d b/std/algorithm/sorting.d index d27870a4a..ee7ed1b0c 100644 --- a/std/algorithm/sorting.d +++ b/std/algorithm/sorting.d @@ -160,7 +160,8 @@ Returns: `true` if the range is sorted, false otherwise. `isSorted` allows duplicates, `isStrictlyMonotonic` not. */ -bool isSorted(alias less = "a < b", Range)(Range r) if (isForwardRange!(Range)) +bool isSorted(alias less = "a < b", Range)(Range r) +if (isForwardRange!(Range)) { if (r.empty) return true; @@ -395,7 +396,7 @@ See_Also: STL's $(HTTP sgi.com/tech/stl/stable_partition.html, stable_partition) */ Range partition(alias predicate, SwapStrategy ss, Range)(Range r) - if (ss == SwapStrategy.stable && isRandomAccessRange!(Range) && hasLength!Range && hasSlicing!Range) +if (ss == SwapStrategy.stable && isRandomAccessRange!(Range) && hasLength!Range && hasSlicing!Range) { import std.algorithm.mutation : bringToFront; @@ -417,7 +418,7 @@ Range partition(alias predicate, SwapStrategy ss, Range)(Range r) ///ditto Range partition(alias predicate, SwapStrategy ss = SwapStrategy.unstable, Range)(Range r) - if (ss != SwapStrategy.stable && isInputRange!Range && hasSwappableElements!Range) +if (ss != SwapStrategy.stable && isInputRange!Range && hasSwappableElements!Range) { import std.algorithm.mutation : swap; alias pred = unaryFun!(predicate); @@ -772,7 +773,7 @@ Params: Returns: $(D true) if $(D r) is partitioned according to predicate $(D pred). */ bool isPartitioned(alias pred, Range)(Range r) - if (isForwardRange!(Range)) +if (isForwardRange!(Range)) { for (; !r.empty; r.popFront()) { @@ -949,8 +950,8 @@ makeIndex( Range, RangeIndex) (Range r, RangeIndex index) - if (isForwardRange!(Range) && isRandomAccessRange!(RangeIndex) - && is(ElementType!(RangeIndex) : ElementType!(Range)*)) +if (isForwardRange!(Range) && isRandomAccessRange!(RangeIndex) + && is(ElementType!(RangeIndex) : ElementType!(Range)*)) { import std.algorithm.internal : addressOf; import std.exception : enforce; @@ -1049,9 +1050,9 @@ unittest } struct Merge(alias less = "a < b", Rs...) - if (Rs.length >= 2 && - allSatisfy!(isInputRange, Rs) && - !is(CommonType!(staticMap!(ElementType, Rs)) == void)) +if (Rs.length >= 2 && + allSatisfy!(isInputRange, Rs) && + !is(CommonType!(staticMap!(ElementType, Rs)) == void)) { public Rs source; private size_t _lastFrontIndex = size_t.max; @@ -1286,9 +1287,9 @@ All of its inputs are assumed to be sorted. This can mean that inputs are `false`). */ Merge!(less, Rs) merge(alias less = "a < b", Rs...)(Rs rs) - if (Rs.length >= 2 && - allSatisfy!(isInputRange, Rs) && - !is(CommonType!(staticMap!(ElementType, Rs)) == void)) +if (Rs.length >= 2 && + allSatisfy!(isInputRange, Rs) && + !is(CommonType!(staticMap!(ElementType, Rs)) == void)) { return typeof(return)(rs); } @@ -1829,12 +1830,12 @@ See_Also: SortedRange!(Range, less) sort(alias less = "a < b", SwapStrategy ss = SwapStrategy.unstable, Range)(Range r) - if (((ss == SwapStrategy.unstable && (hasSwappableElements!Range || - hasAssignableElements!Range)) || - (ss != SwapStrategy.unstable && hasAssignableElements!Range)) && - isRandomAccessRange!Range && - hasSlicing!Range && - hasLength!Range) +if (((ss == SwapStrategy.unstable && (hasSwappableElements!Range || + hasAssignableElements!Range)) || + (ss != SwapStrategy.unstable && hasAssignableElements!Range)) && + isRandomAccessRange!Range && + hasSlicing!Range && + hasLength!Range) /+ Unstable sorting uses the quicksort algorithm, which uses swapAt, which either uses swap(...), requiring swappable elements, or just swaps using assignment. @@ -2888,7 +2889,7 @@ SortedRange!(R, ((a, b) => binaryFun!less(unaryFun!transform(a), unaryFun!transform(b)))) schwartzSort(alias transform, alias less = "a < b", SwapStrategy ss = SwapStrategy.unstable, R)(R r) - if (isRandomAccessRange!R && hasLength!R) +if (isRandomAccessRange!R && hasLength!R) { import std.conv : emplace; import std.string : representation; @@ -3017,7 +3018,7 @@ Params: */ void partialSort(alias less = "a < b", SwapStrategy ss = SwapStrategy.unstable, Range)(Range r, size_t n) - if (isRandomAccessRange!(Range) && hasLength!(Range) && hasSlicing!(Range)) +if (isRandomAccessRange!(Range) && hasLength!(Range) && hasSlicing!(Range)) { partialSort!(less, ss)(r[0 .. n], r[n .. $]); } @@ -3042,9 +3043,9 @@ Params: void partialSort(alias less = "a < b", SwapStrategy ss = SwapStrategy.unstable, Range1, Range2)(Range1 r1, Range2 r2) - if (isRandomAccessRange!(Range1) && hasLength!Range1 && - isInputRange!Range2 && is(ElementType!Range1 == ElementType!Range2) && - hasLvalueElements!Range1 && hasLvalueElements!Range2) +if (isRandomAccessRange!(Range1) && hasLength!Range1 && + isInputRange!Range2 && is(ElementType!Range1 == ElementType!Range2) && + hasLvalueElements!Range1 && hasLvalueElements!Range2) { topN!(less, ss)(r1, r2); sort!(less, ss)(r1); @@ -3092,7 +3093,7 @@ Stable topN has not been implemented yet. auto topN(alias less = "a < b", SwapStrategy ss = SwapStrategy.unstable, Range)(Range r, size_t nth) - if (isRandomAccessRange!(Range) && hasLength!Range && hasSlicing!Range) +if (isRandomAccessRange!(Range) && hasLength!Range && hasSlicing!Range) { static assert(ss == SwapStrategy.unstable, "Stable topN not yet implemented"); @@ -3541,9 +3542,9 @@ Params: auto topN(alias less = "a < b", SwapStrategy ss = SwapStrategy.unstable, Range1, Range2)(Range1 r1, Range2 r2) - if (isRandomAccessRange!(Range1) && hasLength!Range1 && - isInputRange!Range2 && is(ElementType!Range1 == ElementType!Range2) && - hasLvalueElements!Range1 && hasLvalueElements!Range2) +if (isRandomAccessRange!(Range1) && hasLength!Range1 && + isInputRange!Range2 && is(ElementType!Range1 == ElementType!Range2) && + hasLvalueElements!Range1 && hasLvalueElements!Range2) { import std.container : BinaryHeap; @@ -3669,8 +3670,8 @@ Returns: The slice of `target` containing the copied elements. */ TRange topNCopy(alias less = "a < b", SRange, TRange) (SRange source, TRange target, SortOutput sorted = No.sortOutput) - if (isInputRange!(SRange) && isRandomAccessRange!(TRange) - && hasLength!(TRange) && hasSlicing!(TRange)) +if (isInputRange!(SRange) && isRandomAccessRange!(TRange) + && hasLength!(TRange) && hasSlicing!(TRange)) { import std.container : BinaryHeap; @@ -3749,10 +3750,10 @@ ignored. void topNIndex(alias less = "a < b", SwapStrategy ss = SwapStrategy.unstable, Range, RangeIndex) (Range r, RangeIndex index, SortOutput sorted = No.sortOutput) - if (isRandomAccessRange!Range && - isRandomAccessRange!RangeIndex && - hasAssignableElements!RangeIndex && - isIntegral!(ElementType!(RangeIndex))) +if (isRandomAccessRange!Range && + isRandomAccessRange!RangeIndex && + hasAssignableElements!RangeIndex && + isIntegral!(ElementType!(RangeIndex))) { static assert(ss == SwapStrategy.unstable, "Stable swap strategy not implemented yet."); @@ -3782,10 +3783,10 @@ void topNIndex(alias less = "a < b", SwapStrategy ss = SwapStrategy.unstable, void topNIndex(alias less = "a < b", SwapStrategy ss = SwapStrategy.unstable, Range, RangeIndex) (Range r, RangeIndex index, SortOutput sorted = No.sortOutput) - if (isRandomAccessRange!Range && - isRandomAccessRange!RangeIndex && - hasAssignableElements!RangeIndex && - is(ElementType!(RangeIndex) == ElementType!(Range)*)) +if (isRandomAccessRange!Range && + isRandomAccessRange!RangeIndex && + hasAssignableElements!RangeIndex && + is(ElementType!(RangeIndex) == ElementType!(Range)*)) { static assert(ss == SwapStrategy.unstable, "Stable swap strategy not implemented yet."); @@ -4066,8 +4067,8 @@ do */ bool nextPermutation(alias less="a < b", BidirectionalRange) (BidirectionalRange range) - if (isBidirectionalRange!BidirectionalRange && - hasSwappableElements!BidirectionalRange) +if (isBidirectionalRange!BidirectionalRange && + hasSwappableElements!BidirectionalRange) { import std.algorithm.mutation : reverse, swap; import std.algorithm.searching : find; @@ -4323,8 +4324,8 @@ do */ bool nextEvenPermutation(alias less="a < b", BidirectionalRange) (BidirectionalRange range) - if (isBidirectionalRange!BidirectionalRange && - hasSwappableElements!BidirectionalRange) +if (isBidirectionalRange!BidirectionalRange && + hasSwappableElements!BidirectionalRange) { import std.algorithm.mutation : reverse, swap; import std.algorithm.searching : find; diff --git a/std/array.d b/std/array.d index 3a6ff9a3b..d29df2249 100644 --- a/std/array.d +++ b/std/array.d @@ -200,7 +200,8 @@ Returns: a $(D dchar[]), $(D const(dchar)[]), or $(D immutable(dchar)[]) depending on the constness of the input. */ -@trusted ElementType!String[] array(String)(scope String str) if (isNarrowString!String) +@trusted ElementType!String[] array(String)(scope String str) +if (isNarrowString!String) { import std.utf : toUTF32; /* This function is @trusted because the following cast @@ -354,7 +355,7 @@ See_Also: $(REF Tuple, std,typecons), $(REF zip, std,range) */ auto assocArray(Range)(Range r) - if (isInputRange!Range) +if (isInputRange!Range) { import std.typecons : isTuple; @@ -838,8 +839,8 @@ private void copyBackwards(T)(T[] src, T[] dest) stuff = An input range, or any number of implicitly convertible items to insert into $(D array). +/ void insertInPlace(T, U...)(ref T[] array, size_t pos, U stuff) - if (!isSomeString!(T[]) - && allSatisfy!(isInputRangeOrConvertible!T, U) && U.length > 0) +if (!isSomeString!(T[]) + && allSatisfy!(isInputRangeOrConvertible!T, U) && U.length > 0) { static if (allSatisfy!(isInputRangeWithLengthOrConvertible!T, U)) { @@ -897,7 +898,7 @@ void insertInPlace(T, U...)(ref T[] array, size_t pos, U stuff) /// Ditto void insertInPlace(T, U...)(ref T[] array, size_t pos, U stuff) - if (isSomeString!(T[]) && allSatisfy!(isCharOrStringOrDcharRange, U)) +if (isSomeString!(T[]) && allSatisfy!(isCharOrStringOrDcharRange, U)) { static if (is(Unqual!T == T) && allSatisfy!(isInputRangeWithLengthOrConvertible!dchar, U)) @@ -1269,7 +1270,8 @@ Returns an array that consists of $(D s) (which must be an input range) repeated $(D n) times. This function allocates, fills, and returns a new array. For a lazy version, refer to $(REF repeat, std,range). */ -ElementEncodingType!S[] replicate(S)(S s, size_t n) if (isDynamicArray!S) +ElementEncodingType!S[] replicate(S)(S s, size_t n) +if (isDynamicArray!S) { alias RetType = ElementEncodingType!S[]; @@ -1476,9 +1478,10 @@ if (isForwardRange!Range && is(typeof(ElementType!Range.init == Separator.init)) return range.splitter(sep).array; } ///ditto -auto split(Range, Separator)(Range range, Separator sep) if ( - isForwardRange!Range && isForwardRange!Separator - && is(typeof(ElementType!Range.init == ElementType!Separator.init))) +auto split(Range, Separator)(Range range, Separator sep) +if ( + isForwardRange!Range && isForwardRange!Separator + && is(typeof(ElementType!Range.init == ElementType!Separator.init))) { import std.algorithm.iteration : splitter; return range.splitter(sep).array; @@ -1570,10 +1573,10 @@ private enum bool hasCheapIteration(R) = isArray!R; For a lazy version, see $(REF joiner, std,algorithm,iteration) +/ ElementEncodingType!(ElementType!RoR)[] join(RoR, R)(RoR ror, scope R sep) - if (isInputRange!RoR && - isInputRange!(Unqual!(ElementType!RoR)) && - isInputRange!R && - is(Unqual!(ElementType!(ElementType!RoR)) == Unqual!(ElementType!R))) +if (isInputRange!RoR && + isInputRange!(Unqual!(ElementType!RoR)) && + isInputRange!R && + is(Unqual!(ElementType!(ElementType!RoR)) == Unqual!(ElementType!R))) { alias RetType = typeof(return); alias RetTypeElement = Unqual!(ElementEncodingType!RetType); @@ -1647,9 +1650,9 @@ ElementEncodingType!(ElementType!RoR)[] join(RoR, R)(RoR ror, scope R sep) /// Ditto ElementEncodingType!(ElementType!RoR)[] join(RoR, E)(RoR ror, scope E sep) - if (isInputRange!RoR && - isInputRange!(Unqual!(ElementType!RoR)) && - is(E : ElementType!(ElementType!RoR))) +if (isInputRange!RoR && + isInputRange!(Unqual!(ElementType!RoR)) && + is(E : ElementType!(ElementType!RoR))) { alias RetType = typeof(return); alias RetTypeElement = Unqual!(ElementEncodingType!RetType); @@ -1733,8 +1736,8 @@ ElementEncodingType!(ElementType!RoR)[] join(RoR, E)(RoR ror, scope E sep) /// Ditto ElementEncodingType!(ElementType!RoR)[] join(RoR)(RoR ror) - if (isInputRange!RoR && - isInputRange!(Unqual!(ElementType!RoR))) +if (isInputRange!RoR && + isInputRange!(Unqual!(ElementType!RoR))) { alias RetType = typeof(return); alias RetTypeElement = Unqual!(ElementEncodingType!RetType); @@ -2094,9 +2097,9 @@ if (isOutputRange!(Sink, E) && isDynamicArray!(E[]) array without changing the contents of $(D subject). +/ T[] replace(T, Range)(T[] subject, size_t from, size_t to, Range stuff) - if (isInputRange!Range && - (is(ElementType!Range : T) || - isSomeString!(T[]) && is(ElementType!Range : dchar))) +if (isInputRange!Range && + (is(ElementType!Range : T) || + isSomeString!(T[]) && is(ElementType!Range : dchar))) { static if (hasLength!Range && is(ElementEncodingType!Range : T)) { @@ -2210,7 +2213,7 @@ T[] replace(T, Range)(T[] subject, size_t from, size_t to, Range stuff) shrinks the array as needed. +/ void replaceInPlace(T, Range)(ref T[] array, size_t from, size_t to, Range stuff) - if (is(typeof(replace(array, from, to, stuff)))) +if (is(typeof(replace(array, from, to, stuff)))) { static if (isDynamicArray!Range && is(Unqual!(ElementEncodingType!Range) == T) && diff --git a/std/ascii.d b/std/ascii.d index e6016e20f..e63073e47 100644 --- a/std/ascii.d +++ b/std/ascii.d @@ -501,7 +501,7 @@ bool isASCII(dchar c) @safe pure nothrow @nogc ASCII character, otherwise $(D c) itself. +/ auto toLower(C)(C c) - if (is(C : dchar)) +if (is(C : dchar)) { import std.traits : isAggregateType, OriginalType, Unqual; @@ -563,7 +563,7 @@ auto toLower(C)(C c) character, otherwise $(D c) itself. +/ auto toUpper(C)(C c) - if (is(C : dchar)) +if (is(C : dchar)) { import std.traits : isAggregateType, OriginalType, Unqual; diff --git a/std/bigint.d b/std/bigint.d index 4124b2850..a2f3644cc 100644 --- a/std/bigint.d +++ b/std/bigint.d @@ -1086,7 +1086,8 @@ Returns: The absolute value of x. */ -Unsigned!T absUnsign(T)(T x) if (isIntegral!T) +Unsigned!T absUnsign(T)(T x) +if (isIntegral!T) { static if (isSigned!T) { diff --git a/std/bitmanip.d b/std/bitmanip.d index dadfd2630..75c054446 100644 --- a/std/bitmanip.d +++ b/std/bitmanip.d @@ -2146,7 +2146,7 @@ public: Swaps the endianness of the given integral value or character. +/ T swapEndian(T)(T val) @safe pure nothrow @nogc - if (isIntegral!T || isSomeChar!T || isBoolean!T) +if (isIntegral!T || isSomeChar!T || isBoolean!T) { static if (val.sizeof == 1) return val; @@ -2231,7 +2231,7 @@ private ulong swapEndianImpl(ulong val) @trusted pure nothrow @nogc private union EndianSwapper(T) - if (canSwapEndianness!T) +if (canSwapEndianness!T) { Unqual!T value; ubyte[T.sizeof] array; @@ -2258,7 +2258,7 @@ private union EndianSwapper(T) unusable if you tried to transfer it to another machine). +/ auto nativeToBigEndian(T)(T val) @safe pure nothrow @nogc - if (canSwapEndianness!T) +if (canSwapEndianness!T) { return nativeToBigEndianImpl(val); } @@ -2276,7 +2276,7 @@ auto nativeToBigEndian(T)(T val) @safe pure nothrow @nogc } private auto nativeToBigEndianImpl(T)(T val) @safe pure nothrow @nogc - if (isIntegral!T || isSomeChar!T || isBoolean!T) +if (isIntegral!T || isSomeChar!T || isBoolean!T) { EndianSwapper!T es = void; @@ -2289,7 +2289,7 @@ private auto nativeToBigEndianImpl(T)(T val) @safe pure nothrow @nogc } private auto nativeToBigEndianImpl(T)(T val) @safe pure nothrow @nogc - if (isFloatOrDouble!T) +if (isFloatOrDouble!T) { version(LittleEndian) return floatEndianImpl!(T, true)(val); @@ -2380,7 +2380,7 @@ private auto nativeToBigEndianImpl(T)(T val) @safe pure nothrow @nogc can't actually have swapped floating point values as floating point values). +/ T bigEndianToNative(T, size_t n)(ubyte[n] val) @safe pure nothrow @nogc - if (canSwapEndianness!T && n == T.sizeof) +if (canSwapEndianness!T && n == T.sizeof) { return bigEndianToNativeImpl!(T, n)(val); } @@ -2398,8 +2398,8 @@ T bigEndianToNative(T, size_t n)(ubyte[n] val) @safe pure nothrow @nogc } private T bigEndianToNativeImpl(T, size_t n)(ubyte[n] val) @safe pure nothrow @nogc - if ((isIntegral!T || isSomeChar!T || isBoolean!T) && - n == T.sizeof) +if ((isIntegral!T || isSomeChar!T || isBoolean!T) && + n == T.sizeof) { EndianSwapper!T es = void; es.array = val; @@ -2413,7 +2413,7 @@ private T bigEndianToNativeImpl(T, size_t n)(ubyte[n] val) @safe pure nothrow @n } private T bigEndianToNativeImpl(T, size_t n)(ubyte[n] val) @safe pure nothrow @nogc - if (isFloatOrDouble!T && n == T.sizeof) +if (isFloatOrDouble!T && n == T.sizeof) { version(LittleEndian) return cast(T) floatEndianImpl!(n, true)(val); @@ -2432,7 +2432,7 @@ private T bigEndianToNativeImpl(T, size_t n)(ubyte[n] val) @safe pure nothrow @n can't actually have swapped floating point values as floating point values). +/ auto nativeToLittleEndian(T)(T val) @safe pure nothrow @nogc - if (canSwapEndianness!T) +if (canSwapEndianness!T) { return nativeToLittleEndianImpl(val); } @@ -2450,7 +2450,7 @@ auto nativeToLittleEndian(T)(T val) @safe pure nothrow @nogc } private auto nativeToLittleEndianImpl(T)(T val) @safe pure nothrow @nogc - if (isIntegral!T || isSomeChar!T || isBoolean!T) +if (isIntegral!T || isSomeChar!T || isBoolean!T) { EndianSwapper!T es = void; @@ -2463,7 +2463,7 @@ private auto nativeToLittleEndianImpl(T)(T val) @safe pure nothrow @nogc } private auto nativeToLittleEndianImpl(T)(T val) @safe pure nothrow @nogc - if (isFloatOrDouble!T) +if (isFloatOrDouble!T) { version(BigEndian) return floatEndianImpl!(T, true)(val); @@ -2527,7 +2527,7 @@ private auto nativeToLittleEndianImpl(T)(T val) @safe pure nothrow @nogc unusable if you tried to transfer it to another machine). +/ T littleEndianToNative(T, size_t n)(ubyte[n] val) @safe pure nothrow @nogc - if (canSwapEndianness!T && n == T.sizeof) +if (canSwapEndianness!T && n == T.sizeof) { return littleEndianToNativeImpl!T(val); } @@ -2545,8 +2545,8 @@ T littleEndianToNative(T, size_t n)(ubyte[n] val) @safe pure nothrow @nogc } private T littleEndianToNativeImpl(T, size_t n)(ubyte[n] val) @safe pure nothrow @nogc - if ((isIntegral!T || isSomeChar!T || isBoolean!T) && - n == T.sizeof) +if ((isIntegral!T || isSomeChar!T || isBoolean!T) && + n == T.sizeof) { EndianSwapper!T es = void; es.array = val; @@ -2560,8 +2560,8 @@ private T littleEndianToNativeImpl(T, size_t n)(ubyte[n] val) @safe pure nothrow } private T littleEndianToNativeImpl(T, size_t n)(ubyte[n] val) @safe pure nothrow @nogc - if (((isFloatOrDouble!T) && - n == T.sizeof)) +if (((isFloatOrDouble!T) && + n == T.sizeof)) { version(BigEndian) return floatEndianImpl!(n, true)(val); @@ -2570,7 +2570,7 @@ private T littleEndianToNativeImpl(T, size_t n)(ubyte[n] val) @safe pure nothrow } private auto floatEndianImpl(T, bool swap)(T val) @safe pure nothrow @nogc - if (isFloatOrDouble!T) +if (isFloatOrDouble!T) { EndianSwapper!T es = void; es.value = val; @@ -2582,7 +2582,7 @@ private auto floatEndianImpl(T, bool swap)(T val) @safe pure nothrow @nogc } private auto floatEndianImpl(size_t n, bool swap)(ubyte[n] val) @safe pure nothrow @nogc - if (n == 4 || n == 8) +if (n == 4 || n == 8) { static if (n == 4) EndianSwapper!float es = void; else static if (n == 8) EndianSwapper!double es = void; @@ -2672,9 +2672,9 @@ private template canSwapEndianness(T) +/ T peek(T, Endian endianness = Endian.bigEndian, R)(R range) - if (canSwapEndianness!T && - isForwardRange!R && - is(ElementType!R : const ubyte)) +if (canSwapEndianness!T && + isForwardRange!R && + is(ElementType!R : const ubyte)) { static if (hasSlicing!R) const ubyte[T.sizeof] bytes = range[0 .. T.sizeof]; @@ -2699,20 +2699,20 @@ T peek(T, Endian endianness = Endian.bigEndian, R)(R range) /++ Ditto +/ T peek(T, Endian endianness = Endian.bigEndian, R)(R range, size_t index) - if (canSwapEndianness!T && - isForwardRange!R && - hasSlicing!R && - is(ElementType!R : const ubyte)) +if (canSwapEndianness!T && + isForwardRange!R && + hasSlicing!R && + is(ElementType!R : const ubyte)) { return peek!(T, endianness)(range, &index); } /++ Ditto +/ T peek(T, Endian endianness = Endian.bigEndian, R)(R range, size_t* index) - if (canSwapEndianness!T && - isForwardRange!R && - hasSlicing!R && - is(ElementType!R : const ubyte)) +if (canSwapEndianness!T && + isForwardRange!R && + hasSlicing!R && + is(ElementType!R : const ubyte)) { assert(index); @@ -2974,7 +2974,7 @@ T peek(T, Endian endianness = Endian.bigEndian, R)(R range, size_t* index) range = The range to read from. +/ T read(T, Endian endianness = Endian.bigEndian, R)(ref R range) - if (canSwapEndianness!T && isInputRange!R && is(ElementType!R : const ubyte)) +if (canSwapEndianness!T && isInputRange!R && is(ElementType!R : const ubyte)) { static if (hasSlicing!R) { @@ -3220,20 +3220,20 @@ T read(T, Endian endianness = Endian.bigEndian, R)(ref R range) is updated to the index after the bytes read. +/ void write(T, Endian endianness = Endian.bigEndian, R)(R range, T value, size_t index) - if (canSwapEndianness!T && - isForwardRange!R && - hasSlicing!R && - is(ElementType!R : ubyte)) +if (canSwapEndianness!T && + isForwardRange!R && + hasSlicing!R && + is(ElementType!R : ubyte)) { write!(T, endianness)(range, value, &index); } /++ Ditto +/ void write(T, Endian endianness = Endian.bigEndian, R)(R range, T value, size_t* index) - if (canSwapEndianness!T && - isForwardRange!R && - hasSlicing!R && - is(ElementType!R : ubyte)) +if (canSwapEndianness!T && + isForwardRange!R && + hasSlicing!R && + is(ElementType!R : ubyte)) { assert(index); @@ -3564,7 +3564,7 @@ void write(T, Endian endianness = Endian.bigEndian, R)(R range, T value, size_t* value = The value to _append. +/ void append(T, Endian endianness = Endian.bigEndian, R)(R range, T value) - if (canSwapEndianness!T && isOutputRange!(R, ubyte)) +if (canSwapEndianness!T && isOutputRange!(R, ubyte)) { static if (endianness == Endian.bigEndian) immutable bytes = nativeToBigEndian!T(value); @@ -3765,7 +3765,7 @@ Counts the number of set bits in the binary representation of $(D value). For signed integers, the sign bit is included in the count. */ private uint countBitsSet(T)(T value) @nogc pure nothrow - if (isIntegral!T) +if (isIntegral!T) { // http://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetParallel static if (T.sizeof == 8) @@ -3904,7 +3904,7 @@ Index 0 corresponds to the least significant bit. For signed integers, the highest index corresponds to the sign bit. */ auto bitsSet(T)(T value) @nogc pure nothrow - if (isIntegral!T) +if (isIntegral!T) { return BitsSet!T(value); } diff --git a/std/complex.d b/std/complex.d index 0441f215e..bf933b7bc 100644 --- a/std/complex.d +++ b/std/complex.d @@ -34,7 +34,8 @@ import std.traits; be $(D Complex!double). Otherwise, the return type is deduced using $(D std.traits.CommonType!(R, I)). */ -auto complex(R)(R re) @safe pure nothrow @nogc if (is(R : double)) +auto complex(R)(R re) @safe pure nothrow @nogc +if (is(R : double)) { static if (isFloatingPoint!R) return Complex!R(re, 0); @@ -44,7 +45,7 @@ auto complex(R)(R re) @safe pure nothrow @nogc if (is(R : double)) /// ditto auto complex(R, I)(R re, I im) @safe pure nothrow @nogc - if (is(R : double) && is(I : double)) +if (is(R : double) && is(I : double)) { static if (isFloatingPoint!R || isFloatingPoint!I) return Complex!(CommonType!(R, I))(re, im); @@ -95,7 +96,8 @@ auto complex(R, I)(R re, I im) @safe pure nothrow @nogc /** A complex number parametrised by a type $(D T), which must be either $(D float), $(D double) or $(D real). */ -struct Complex(T) if (isFloatingPoint!T) +struct Complex(T) +if (isFloatingPoint!T) { import std.format : FormatSpec; import std.range.primitives : isOutputRange; @@ -658,7 +660,8 @@ struct Complex(T) if (isFloatingPoint!T) --- The above will work if T is both real and complex. */ -template Complex(T) if (is(T R == Complex!R)) +template Complex(T) +if (is(T R == Complex!R)) { alias Complex = T; } @@ -727,7 +730,7 @@ T sqAbs(T)(Complex!T z) @safe pure nothrow @nogc /// ditto T sqAbs(T)(T x) @safe pure nothrow @nogc - if (isFloatingPoint!T) +if (isFloatingPoint!T) { return x*x; } diff --git a/std/concurrency.d b/std/concurrency.d index 1822006ac..e182ff8f6 100644 --- a/std/concurrency.d +++ b/std/concurrency.d @@ -479,7 +479,7 @@ private template isSpawnable(F, T...) * --- */ Tid spawn(F, T...)( F fn, T args ) - if ( isSpawnable!(F, T) ) +if ( isSpawnable!(F, T) ) { static assert( !hasLocalAliasing!(T), "Aliases to mutable thread-local data not allowed." ); @@ -507,7 +507,7 @@ Tid spawn(F, T...)( F fn, T args ) * A Tid representing the new thread. */ Tid spawnLinked(F, T...)( F fn, T args ) - if ( isSpawnable!(F, T) ) +if ( isSpawnable!(F, T) ) { static assert( !hasLocalAliasing!(T), "Aliases to mutable thread-local data not allowed." ); @@ -519,7 +519,7 @@ Tid spawnLinked(F, T...)( F fn, T args ) * */ private Tid _spawn(F, T...)( bool linked, F fn, T args ) - if ( isSpawnable!(F, T) ) +if ( isSpawnable!(F, T) ) { // TODO: MessageList and &exec should be shared. auto spawnTid = Tid( new MessageBox ); diff --git a/std/container/rbtree.d b/std/container/rbtree.d index 52cfb71c2..034d52830 100644 --- a/std/container/rbtree.d +++ b/std/container/rbtree.d @@ -736,7 +736,7 @@ private struct RBRange(N) * inserted after all existing duplicate elements. */ final class RedBlackTree(T, alias less = "a < b", bool allowDuplicates = false) - if (is(typeof(binaryFun!less(T.init, T.init)))) +if (is(typeof(binaryFun!less(T.init, T.init)))) { import std.meta : allSatisfy; import std.range.primitives : isInputRange, walkLength; @@ -1842,14 +1842,14 @@ auto redBlackTree(bool allowDuplicates, E)(E[] elems...) /++ Ditto +/ auto redBlackTree(alias less, E)(E[] elems...) - if (is(typeof(binaryFun!less(E.init, E.init)))) +if (is(typeof(binaryFun!less(E.init, E.init)))) { return new RedBlackTree!(E, less)(elems); } /++ Ditto +/ auto redBlackTree(alias less, bool allowDuplicates, E)(E[] elems...) - if (is(typeof(binaryFun!less(E.init, E.init)))) +if (is(typeof(binaryFun!less(E.init, E.init)))) { //We shouldn't need to instantiate less here, but for some reason, //dmd can't handle it if we don't (even though the template which @@ -1885,8 +1885,8 @@ if ( is(typeof(binaryFun!less((ElementType!Stuff).init, (ElementType!Stuff).init /++ Ditto +/ auto redBlackTree(alias less, bool allowDuplicates, Stuff)(Stuff range) - if ( is(typeof(binaryFun!less((ElementType!Stuff).init, (ElementType!Stuff).init))) - && isInputRange!Stuff && !isArray!(Stuff)) +if ( is(typeof(binaryFun!less((ElementType!Stuff).init, (ElementType!Stuff).init))) + && isInputRange!Stuff && !isArray!(Stuff)) { //We shouldn't need to instantiate less here, but for some reason, //dmd can't handle it if we don't (even though the template which diff --git a/std/container/util.d b/std/container/util.d index d9718d262..6564989eb 100644 --- a/std/container/util.d +++ b/std/container/util.d @@ -101,7 +101,7 @@ unittest * Convenience function for constructing a generic container. */ template make(alias Container, Args...) - if (!is(Container)) +if (!is(Container)) { import std.range : isInputRange, isInfinite; import std.traits : isDynamicArray; diff --git a/std/conv.d b/std/conv.d index e1acaef24..50e1456d2 100644 --- a/std/conv.d +++ b/std/conv.d @@ -85,7 +85,7 @@ private void parseCheck(alias source)(dchar c, string fn = __FILE__, size_t ln = private { T toStr(T, S)(S src) - if (isSomeString!T) + if (isSomeString!T) { // workaround for Bugzilla 14198 static if (is(S == bool) && is(typeof({ T s = "string"; }))) @@ -409,8 +409,8 @@ If the source type is implicitly convertible to the target type, $(D to) simply performs the implicit conversion. */ private T toImpl(T, S)(S value) - if (isImplicitlyConvertible!(S, T) && - !isEnumStrToStr!(S, T) && !isNullToStr!(S, T)) +if (isImplicitlyConvertible!(S, T) && + !isEnumStrToStr!(S, T) && !isNullToStr!(S, T)) { template isSignedInt(T) { @@ -523,7 +523,7 @@ private T toImpl(T, S)(S value) Converting static arrays forwards to their dynamic counterparts. */ private T toImpl(T, S)(ref S s) - if (isStaticArray!S) +if (isStaticArray!S) { return toImpl!(T, typeof(s[0])[])(s); } @@ -539,10 +539,10 @@ private T toImpl(T, S)(ref S s) When source type supports member template function opCast, it is used. */ private T toImpl(T, S)(S value) - if (!isImplicitlyConvertible!(S, T) && - is(typeof(S.init.opCast!T()) : T) && - !isExactSomeString!T && - !is(typeof(T(value)))) +if (!isImplicitlyConvertible!(S, T) && + is(typeof(S.init.opCast!T()) : T) && + !isExactSomeString!T && + !is(typeof(T(value)))) { return value.opCast!T(); } @@ -590,8 +590,8 @@ $(UL $(LI If target type is struct, $(D T(value)) is used.) $(LI If target type is class, $(D new T(value)) is used.)) */ private T toImpl(T, S)(S value) - if (!isImplicitlyConvertible!(S, T) && - is(T == struct) && is(typeof(T(value)))) +if (!isImplicitlyConvertible!(S, T) && + is(T == struct) && is(typeof(T(value)))) { return T(value); } @@ -639,8 +639,8 @@ private T toImpl(T, S)(S value) /// ditto private T toImpl(T, S)(S value) - if (!isImplicitlyConvertible!(S, T) && - is(T == class) && is(typeof(new T(value)))) +if (!isImplicitlyConvertible!(S, T) && + is(T == class) && is(typeof(new T(value)))) { return new T(value); } @@ -712,9 +712,9 @@ Object-to-object conversions by dynamic casting throw exception when the source non-null and the target is null. */ private T toImpl(T, S)(S value) - if (!isImplicitlyConvertible!(S, T) && - (is(S == class) || is(S == interface)) && !is(typeof(value.opCast!T()) : T) && - (is(T == class) || is(T == interface)) && !is(typeof(new T(value)))) +if (!isImplicitlyConvertible!(S, T) && + (is(S == class) || is(S == interface)) && !is(typeof(value.opCast!T()) : T) && + (is(T == class) || is(T == interface)) && !is(typeof(new T(value)))) { static if (is(T == immutable)) { @@ -772,7 +772,8 @@ private T toImpl(T, S)(S value) alias toShared(T) = shared T; alias toSharedConst(T) = shared const T; alias toImmutable(T) = immutable T; - template AddModifier(int n) if (0 <= n && n < 5) + template AddModifier(int n) + if (0 <= n && n < 5) { static if (n == 0) alias AddModifier = Identity; else static if (n == 1) alias AddModifier = toConst; @@ -832,9 +833,9 @@ private T toImpl(T, S)(S value) Handles type _to string conversions */ private T toImpl(T, S)(S value) - if (!(isImplicitlyConvertible!(S, T) && - !isEnumStrToStr!(S, T) && !isNullToStr!(S, T)) && - !isInfinite!S && isExactSomeString!T) +if (!(isImplicitlyConvertible!(S, T) && + !isEnumStrToStr!(S, T) && !isNullToStr!(S, T)) && + !isInfinite!S && isExactSomeString!T) { static if (isExactSomeString!S && value[0].sizeof == ElementEncodingType!T.sizeof) { @@ -1229,8 +1230,8 @@ if (is (T == immutable) && isExactSomeString!T && is(S == enum)) // ditto @trusted pure private T toImpl(T, S)(S value, uint radix, LetterCase letterCase = LetterCase.upper) - if (isIntegral!S && - isExactSomeString!T) +if (isIntegral!S && + isExactSomeString!T) in { assert(radix >= 2 && radix <= 36); @@ -1309,9 +1310,9 @@ Narrowing numeric-numeric conversions throw when the value does not fit in the narrower type. */ private T toImpl(T, S)(S value) - if (!isImplicitlyConvertible!(S, T) && - (isNumeric!S || isSomeChar!S || isBoolean!S) && - (isNumeric!T || isSomeChar!T || isBoolean!T) && !is(T == enum)) +if (!isImplicitlyConvertible!(S, T) && + (isNumeric!S || isSomeChar!S || isBoolean!S) && + (isNumeric!T || isSomeChar!T || isBoolean!T) && !is(T == enum)) { enum sSmallest = mostNegative!S; enum tSmallest = mostNegative!T; @@ -1402,9 +1403,9 @@ Array-to-array conversion (except when target is a string type) converts each element in turn by using $(D to). */ private T toImpl(T, S)(S value) - if (!isImplicitlyConvertible!(S, T) && - !isSomeString!S && isDynamicArray!S && - !isExactSomeString!T && isArray!T) +if (!isImplicitlyConvertible!(S, T) && + !isSomeString!S && isDynamicArray!S && + !isExactSomeString!T && isArray!T) { alias E = typeof(T.init[0]); @@ -1484,8 +1485,8 @@ Associative array to associative array conversion converts each key and each value in turn. */ private T toImpl(T, S)(S value) - if (isAssociativeArray!S && - isAssociativeArray!T && !is(T == enum)) +if (isAssociativeArray!S && + isAssociativeArray!T && !is(T == enum)) { /* This code is potentially unsafe. */ @@ -1717,8 +1718,8 @@ $(UL $(LI When the source is a narrow string, normal text parsing occurs.)) */ private T toImpl(T, S)(S value) - if (isInputRange!S && isSomeChar!(ElementEncodingType!S) && - !isExactSomeString!T && is(typeof(parse!T(value)))) +if (isInputRange!S && isSomeChar!(ElementEncodingType!S) && + !isExactSomeString!T && is(typeof(parse!T(value)))) { scope(success) { @@ -1732,8 +1733,8 @@ private T toImpl(T, S)(S value) /// ditto private T toImpl(T, S)(S value, uint radix) - if (isInputRange!S && !isInfinite!S && isSomeChar!(ElementEncodingType!S) && - !isExactSomeString!T && is(typeof(parse!T(value, radix)))) +if (isInputRange!S && !isInfinite!S && isSomeChar!(ElementEncodingType!S) && + !isExactSomeString!T && is(typeof(parse!T(value, radix)))) { scope(success) { @@ -1791,9 +1792,9 @@ a ConvException is thrown. Enums with floating-point or string base types are not supported. */ private T toImpl(T, S)(S value) - if (is(T == enum) && !is(S == enum) - && is(typeof(value == OriginalType!T.init)) - && !isFloatingPoint!(OriginalType!T) && !isSomeString!(OriginalType!T)) +if (is(T == enum) && !is(S == enum) + && is(typeof(value == OriginalType!T.init)) + && !isFloatingPoint!(OriginalType!T) && !isSomeString!(OriginalType!T)) { foreach (Member; EnumMembers!T) { @@ -1889,9 +1890,9 @@ Note: to `parse` and do not require lvalues. */ Target parse(Target, Source)(ref Source source) - if (isInputRange!Source && - isSomeChar!(ElementType!Source) && - is(Unqual!Target == bool)) +if (isInputRange!Source && + isSomeChar!(ElementType!Source) && + is(Unqual!Target == bool)) { import std.ascii : toLower; @@ -1985,8 +1986,8 @@ Throws: if no character of the input was meaningfully converted. */ Target parse(Target, Source)(ref Source s) - if (isSomeChar!(ElementType!Source) && - isIntegral!Target && !is(Target == enum)) +if (isSomeChar!(ElementType!Source) && + isIntegral!Target && !is(Target == enum)) { static if (Target.sizeof < int.sizeof) { @@ -2348,8 +2349,8 @@ Lerr: /// ditto Target parse(Target, Source)(ref Source source, uint radix) - if (isSomeChar!(ElementType!Source) && - isIntegral!Target && !is(Target == enum)) +if (isSomeChar!(ElementType!Source) && + isIntegral!Target && !is(Target == enum)) in { assert(radix >= 2 && radix <= 36); @@ -2460,8 +2461,8 @@ body * represented by `s`. */ Target parse(Target, Source)(ref Source s) - if (isSomeString!Source && !is(Source == enum) && - is(Target == enum)) +if (isSomeString!Source && !is(Source == enum) && + is(Target == enum)) { import std.algorithm.searching : startsWith; Target result; @@ -2543,8 +2544,8 @@ Target parse(Target, Source)(ref Source s) * parsed, or if an overflow occurred. */ Target parse(Target, Source)(ref Source source) - if (isInputRange!Source && isSomeChar!(ElementType!Source) && !is(Source == enum) && - isFloatingPoint!Target && !is(Target == enum)) +if (isInputRange!Source && isSomeChar!(ElementType!Source) && !is(Source == enum) && + isFloatingPoint!Target && !is(Target == enum)) { import std.ascii : isDigit, isAlpha, toLower, toUpper, isHexDigit; import std.exception : enforce; @@ -3243,8 +3244,8 @@ Throws: A $(LREF ConvException) if the range is empty. */ Target parse(Target, Source)(ref Source s) - if (isSomeString!Source && !is(Source == enum) && - staticIndexOf!(Unqual!Target, dchar, Unqual!(ElementEncodingType!Source)) >= 0) +if (isSomeString!Source && !is(Source == enum) && + staticIndexOf!(Unqual!Target, dchar, Unqual!(ElementEncodingType!Source)) >= 0) { if (s.empty) throw convError!(Source, Target)(s); @@ -3282,8 +3283,8 @@ Target parse(Target, Source)(ref Source s) /// ditto Target parse(Target, Source)(ref Source s) - if (!isSomeString!Source && isInputRange!Source && isSomeChar!(ElementType!Source) && - isSomeChar!Target && Target.sizeof >= ElementType!Source.sizeof && !is(Target == enum)) +if (!isSomeString!Source && isInputRange!Source && isSomeChar!(ElementType!Source) && + isSomeChar!Target && Target.sizeof >= ElementType!Source.sizeof && !is(Target == enum)) { if (s.empty) throw convError!(Source, Target)(s); @@ -3345,9 +3346,9 @@ Throws: A $(LREF ConvException) if the range doesn't represent `null`. */ Target parse(Target, Source)(ref Source s) - if (isInputRange!Source && - isSomeChar!(ElementType!Source) && - is(Unqual!Target == typeof(null))) +if (isInputRange!Source && + isSomeChar!(ElementType!Source) && + is(Unqual!Target == typeof(null))) { import std.ascii : toLower; foreach (c; "null") @@ -3421,8 +3422,8 @@ package void skipWS(R)(ref R r) * An array of type `Target` */ Target parse(Target, Source)(ref Source s, dchar lbracket = '[', dchar rbracket = ']', dchar comma = ',') - if (isSomeString!Source && !is(Source == enum) && - isDynamicArray!Target && !is(Target == enum)) +if (isSomeString!Source && !is(Source == enum) && + isDynamicArray!Target && !is(Target == enum)) { import std.array : appender; @@ -3555,8 +3556,8 @@ Target parse(Target, Source)(ref Source s, dchar lbracket = '[', dchar rbracket /// ditto Target parse(Target, Source)(ref Source s, dchar lbracket = '[', dchar rbracket = ']', dchar comma = ',') - if (isExactSomeString!Source && - isStaticArray!Target && !is(Target == enum)) +if (isExactSomeString!Source && + isStaticArray!Target && !is(Target == enum)) { static if (hasIndirections!Target) Target result = Target.init[0].init; @@ -3639,8 +3640,8 @@ Lfewerr: */ Target parse(Target, Source)(ref Source s, dchar lbracket = '[', dchar rbracket = ']', dchar keyval = ':', dchar comma = ',') - if (isSomeString!Source && !is(Source == enum) && - isAssociativeArray!Target && !is(Target == enum)) +if (isSomeString!Source && !is(Source == enum) && + isAssociativeArray!Target && !is(Target == enum)) { alias KeyType = typeof(Target.init.keys[0]); alias ValType = typeof(Target.init.values[0]); @@ -3706,7 +3707,7 @@ Target parse(Target, Source)(ref Source s, dchar lbracket = '[', } private dchar parseEscape(Source)(ref Source s) - if (isInputRange!Source && isSomeChar!(ElementType!Source)) +if (isInputRange!Source && isSomeChar!(ElementType!Source)) { parseCheck!s('\\'); if (s.empty) @@ -3821,8 +3822,8 @@ private dchar parseEscape(Source)(ref Source s) // Undocumented Target parseElement(Target, Source)(ref Source s) - if (isInputRange!Source && isSomeChar!(ElementType!Source) && !is(Source == enum) && - isExactSomeString!Target) +if (isInputRange!Source && isSomeChar!(ElementType!Source) && !is(Source == enum) && + isExactSomeString!Target) { import std.array : appender; auto result = appender!Target(); @@ -3864,8 +3865,8 @@ Target parseElement(Target, Source)(ref Source s) // ditto Target parseElement(Target, Source)(ref Source s) - if (isInputRange!Source && isSomeChar!(ElementType!Source) && !is(Source == enum) && - isSomeChar!Target && !is(Target == enum)) +if (isInputRange!Source && isSomeChar!(ElementType!Source) && !is(Source == enum) && + isSomeChar!Target && !is(Target == enum)) { Target c; @@ -3886,8 +3887,8 @@ Target parseElement(Target, Source)(ref Source s) // ditto Target parseElement(Target, Source)(ref Source s) - if (isInputRange!Source && isSomeChar!(ElementType!Source) && - !isSomeString!Target && !isSomeChar!Target) +if (isInputRange!Source && isSomeChar!(ElementType!Source) && + !isSomeString!Target && !isSomeChar!Target) { return parse!Target(s); } @@ -3897,21 +3898,26 @@ Target parseElement(Target, Source)(ref Source s) * Convenience functions for converting one or more arguments * of any type into _text (the three character widths). */ -string text(T...)(T args) if (T.length > 0) { return textImpl!string(args); } +string text(T...)(T args) +if (T.length > 0) { return textImpl!string(args); } // @@@DEPRECATED_2017-06@@@ deprecated("Calling `text` with 0 arguments is deprecated") -string text(T...)(T args) if (T.length == 0) { return textImpl!string(args); } +string text(T...)(T args) +if (T.length == 0) { return textImpl!string(args); } ///ditto -wstring wtext(T...)(T args) if (T.length > 0) { return textImpl!wstring(args); } +wstring wtext(T...)(T args) +if (T.length > 0) { return textImpl!wstring(args); } // @@@DEPRECATED_2017-06@@@ deprecated("Calling `wtext` with 0 arguments is deprecated") -wstring wtext(T...)(T args) if (T.length == 0) { return textImpl!wstring(args); } +wstring wtext(T...)(T args) +if (T.length == 0) { return textImpl!wstring(args); } ///ditto -dstring dtext(T...)(T args) if (T.length > 0) { return textImpl!dstring(args); } +dstring dtext(T...)(T args) +if (T.length > 0) { return textImpl!dstring(args); } /// @safe unittest @@ -3923,7 +3929,8 @@ dstring dtext(T...)(T args) if (T.length > 0) { return textImpl!dstring(args); } // @@@DEPRECATED_2017-06@@@ deprecated("Calling `dtext` with 0 arguments is deprecated") -dstring dtext(T...)(T args) if (T.length == 0) { return textImpl!dstring(args); } +dstring dtext(T...)(T args) +if (T.length == 0) { return textImpl!dstring(args); } private S textImpl(S, U...)(U args) { @@ -3977,7 +3984,7 @@ See_Also: $(LREF parse) for parsing octal strings at runtime. */ template octal(string num) - if (isOctalLiteral(num)) +if (isOctalLiteral(num)) { static if ((octalFitsInInt!num && !literalIsLong!num) && !literalIsUnsigned!num) enum octal = octal!int(num); @@ -3993,7 +4000,7 @@ template octal(string num) /// Ditto template octal(alias decimalInteger) - if (isIntegral!(typeof(decimalInteger))) +if (isIntegral!(typeof(decimalInteger))) { enum octal = octal!(typeof(decimalInteger))(to!string(decimalInteger)); } @@ -4490,7 +4497,7 @@ $(D T) is $(D @safe). Returns: A pointer to the newly constructed object. */ T* emplace(T, Args...)(void[] chunk, auto ref Args args) - if (!is(T == class)) +if (!is(T == class)) { testEmplaceChunk(chunk, T.sizeof, T.alignof, T.stringof); emplaceRef!(T, Unqual!T)(*cast(Unqual!T*) chunk.ptr, args); @@ -5435,7 +5442,7 @@ pure nothrow @safe /* @nogc */ unittest // Undocumented for the time being void toTextRange(T, W)(T value, W writer) - if (isIntegral!T && isOutputRange!(W, char)) +if (isIntegral!T && isOutputRange!(W, char)) { char[value.sizeof * 4] buffer = void; uint i = cast(uint) (buffer.length - 1); @@ -5474,7 +5481,8 @@ void toTextRange(T, W)(T value, W writer) Note that the result is always mutable even if the original type was const or immutable. In order to retain the constness, use $(REF Unsigned, std,traits). */ -auto unsigned(T)(T x) if (isIntegral!T) +auto unsigned(T)(T x) +if (isIntegral!T) { return cast(Unqual!(Unsigned!T))x; } @@ -5522,7 +5530,8 @@ auto unsigned(T)(T x) if (isIntegral!T) } } -auto unsigned(T)(T x) if (isSomeChar!T) +auto unsigned(T)(T x) +if (isSomeChar!T) { // All characters are unsigned static assert(T.min == 0); @@ -5549,7 +5558,8 @@ auto unsigned(T)(T x) if (isSomeChar!T) Note that the result is always mutable even if the original type was const or immutable. In order to retain the constness, use $(REF Signed, std,traits). */ -auto signed(T)(T x) if (isIntegral!T) +auto signed(T)(T x) +if (isIntegral!T) { return cast(Unqual!(Signed!T))x; } @@ -5896,9 +5906,9 @@ private auto hexStrImpl(String)(scope String hexData) auto toChars(ubyte radix = 10, Char = char, LetterCase letterCase = LetterCase.lower, T)(T value) pure nothrow @nogc @safe - if ((radix == 2 || radix == 8 || radix == 10 || radix == 16) && - (is(Unqual!T == uint) || is(Unqual!T == ulong) || - radix == 10 && (is(Unqual!T == int) || is(Unqual!T == long)))) +if ((radix == 2 || radix == 8 || radix == 10 || radix == 16) && + (is(Unqual!T == uint) || is(Unqual!T == ulong) || + radix == 10 && (is(Unqual!T == int) || is(Unqual!T == long)))) { alias UT = Unqual!T; diff --git a/std/csv.d b/std/csv.d index 46e3dc9ca..0490df4aa 100644 --- a/std/csv.d +++ b/std/csv.d @@ -311,9 +311,9 @@ enum Malformed */ auto csvReader(Contents = string,Malformed ErrorLevel = Malformed.throwException, Range, Separator = char)(Range input, Separator delimiter = ',', Separator quote = '"') - if (isInputRange!Range && is(Unqual!(ElementType!Range) == dchar) - && isSomeChar!(Separator) - && !is(Contents T : T[U], U : string)) +if (isInputRange!Range && is(Unqual!(ElementType!Range) == dchar) + && isSomeChar!(Separator) + && !is(Contents T : T[U], U : string)) { return CsvReader!(Contents,ErrorLevel,Range, Unqual!(ElementType!Range),string[]) @@ -399,10 +399,10 @@ auto csvReader(Contents = string, Range, Header, Separator = char) (Range input, Header header, Separator delimiter = ',', Separator quote = '"') - if (isInputRange!Range && is(Unqual!(ElementType!Range) == dchar) - && isSomeChar!(Separator) - && isForwardRange!Header - && isSomeString!(ElementType!Header)) +if (isInputRange!Range && is(Unqual!(ElementType!Range) == dchar) + && isSomeChar!(Separator) + && isForwardRange!Header + && isSomeString!(ElementType!Header)) { return CsvReader!(Contents,ErrorLevel,Range, Unqual!(ElementType!Range),Header) @@ -415,9 +415,9 @@ auto csvReader(Contents = string, Range, Header, Separator = char) (Range input, Header header, Separator delimiter = ',', Separator quote = '"') - if (isInputRange!Range && is(Unqual!(ElementType!Range) == dchar) - && isSomeChar!(Separator) - && is(Header : typeof(null))) +if (isInputRange!Range && is(Unqual!(ElementType!Range) == dchar) + && isSomeChar!(Separator) + && is(Header : typeof(null))) { return CsvReader!(Contents,ErrorLevel,Range, Unqual!(ElementType!Range),string[]) @@ -783,9 +783,9 @@ private pure struct Input(Range, Malformed ErrorLevel) * Malformed).ignore if best guess processing should take place. */ private struct CsvReader(Contents, Malformed ErrorLevel, Range, Separator, Header) - if (isSomeChar!Separator && isInputRange!Range - && is(Unqual!(ElementType!Range) == dchar) - && isForwardRange!Header && isSomeString!(ElementType!Header)) +if (isSomeChar!Separator && isInputRange!Range + && is(Unqual!(ElementType!Range) == dchar) + && isForwardRange!Header && isSomeString!(ElementType!Header)) { private: Input!(Range, ErrorLevel)* _input; @@ -1132,7 +1132,7 @@ public: * requested $(D Contents) type is neither a structure or an associative array. */ private struct CsvRecord(Contents, Malformed ErrorLevel, Range, Separator) - if (!is(Contents == class) && !is(Contents == struct)) +if (!is(Contents == class) && !is(Contents == struct)) { import std.array : appender; private: @@ -1367,9 +1367,9 @@ void csvNextToken(Range, Malformed ErrorLevel = Malformed.throwException, (ref Range input, ref Output ans, Separator sep, Separator quote, bool startQuoted = false) - if (isSomeChar!Separator && isInputRange!Range - && is(Unqual!(ElementType!Range) == dchar) - && isOutputRange!(Output, dchar)) +if (isSomeChar!Separator && isInputRange!Range + && is(Unqual!(ElementType!Range) == dchar) + && isOutputRange!(Output, dchar)) { bool quoted = startQuoted; bool escQuote; diff --git a/std/datetime.d b/std/datetime.d index d0b6e920d..928a2ceea 100644 --- a/std/datetime.d +++ b/std/datetime.d @@ -25969,11 +25969,11 @@ private: dayOfWeek = The week that each time point in the range will be. +/ static TP delegate(in TP) everyDayOfWeek(TP, Direction dir = Direction.fwd)(DayOfWeek dayOfWeek) nothrow - if (isTimePoint!TP && - (dir == Direction.fwd || dir == Direction.bwd) && - __traits(hasMember, TP, "dayOfWeek") && - !__traits(isStaticFunction, TP.dayOfWeek) && - is(typeof(TP.dayOfWeek) == DayOfWeek)) +if (isTimePoint!TP && + (dir == Direction.fwd || dir == Direction.bwd) && + __traits(hasMember, TP, "dayOfWeek") && + !__traits(isStaticFunction, TP.dayOfWeek) && + is(typeof(TP.dayOfWeek) == DayOfWeek)) { TP func(in TP tp) { @@ -26073,11 +26073,11 @@ static TP delegate(in TP) everyDayOfWeek(TP, Direction dir = Direction.fwd)(DayO month = The month that each time point in the range will be in. +/ static TP delegate(in TP) everyMonth(TP, Direction dir = Direction.fwd)(int month) - if (isTimePoint!TP && - (dir == Direction.fwd || dir == Direction.bwd) && - __traits(hasMember, TP, "month") && - !__traits(isStaticFunction, TP.month) && - is(typeof(TP.month) == Month)) +if (isTimePoint!TP && + (dir == Direction.fwd || dir == Direction.bwd) && + __traits(hasMember, TP, "month") && + !__traits(isStaticFunction, TP.month) && + is(typeof(TP.month) == Month)) { enforceValid!"months"(month); @@ -26197,9 +26197,9 @@ static TP delegate(in TP) everyMonth(TP, Direction dir = Direction.fwd)(int mont +/ static TP delegate(in TP) everyDuration(TP, Direction dir = Direction.fwd, D) (D duration) nothrow - if (isTimePoint!TP && - __traits(compiles, TP.init + duration) && - (dir == Direction.fwd || dir == Direction.bwd)) +if (isTimePoint!TP && + __traits(compiles, TP.init + duration) && + (dir == Direction.fwd || dir == Direction.bwd)) { TP func(in TP tp) { @@ -26300,11 +26300,11 @@ static TP delegate(in TP) everyDuration(TP, Direction dir = Direction.fwd, D) int months = 0, AllowDayOverflow allowOverflow = Yes.allowDayOverflow, D duration = dur!"days"(0)) nothrow - if (isTimePoint!TP && - __traits(compiles, TP.init + duration) && - __traits(compiles, TP.init.add!"years"(years)) && - __traits(compiles, TP.init.add!"months"(months)) && - (dir == Direction.fwd || dir == Direction.bwd)) +if (isTimePoint!TP && + __traits(compiles, TP.init + duration) && + __traits(compiles, TP.init.add!"years"(years)) && + __traits(compiles, TP.init.add!"months"(months)) && + (dir == Direction.fwd || dir == Direction.bwd)) { TP func(in TP tp) { @@ -26455,7 +26455,7 @@ static TP delegate(in TP) everyDuration(TP, Direction dir = Direction.fwd, D) excluded will treat $(D begin) as included and $(D end) as excluded. +/ struct IntervalRange(TP, Direction dir) - if (isTimePoint!TP && dir != Direction.both) +if (isTimePoint!TP && dir != Direction.both) { public: @@ -26998,7 +26998,7 @@ private: a $(LREF DateTimeException) will be thrown. +/ struct PosInfIntervalRange(TP) - if (isTimePoint!TP) +if (isTimePoint!TP) { public: @@ -27288,7 +27288,7 @@ private: whether $(D end) is included or excluded will treat $(D end) as excluded. +/ struct NegInfIntervalRange(TP) - if (isTimePoint!TP) +if (isTimePoint!TP) { public: @@ -32343,7 +32343,7 @@ long unixTimeToStdTime(long unixTime) @safe pure nothrow SysTime.toUnixTime +/ T stdTimeToUnixTime(T = time_t)(long stdTime) @safe pure nothrow - if (is(T == int) || is(T == long)) +if (is(T == int) || is(T == long)) { immutable unixTime = convert!("hnsecs", "seconds")(stdTime - 621_355_968_000_000_000L); @@ -32831,8 +32831,8 @@ SysTime parseRFC822DateTime()(in char[] value) @safe /++ Ditto +/ SysTime parseRFC822DateTime(R)(R value) @safe - if (isRandomAccessRange!R && hasSlicing!R && hasLength!R && - (is(Unqual!(ElementType!R) == char) || is(Unqual!(ElementType!R) == ubyte))) +if (isRandomAccessRange!R && hasSlicing!R && hasLength!R && + (is(Unqual!(ElementType!R) == char) || is(Unqual!(ElementType!R) == ubyte))) { import std.algorithm.searching : find, all; import std.ascii : isDigit, isAlpha, isPrintable; @@ -33649,7 +33649,7 @@ int cmpTimeUnits(string lhs, string rhs) @safe pure ) +/ template CmpTimeUnits(string lhs, string rhs) - if (validTimeUnits(lhs, rhs)) +if (validTimeUnits(lhs, rhs)) { enum CmpTimeUnits = cmpTimeUnitsCTFE(lhs, rhs); } @@ -33709,10 +33709,10 @@ private int cmpTimeUnitsCTFE(string lhs, string rhs) @safe pure nothrow value = The number to validate. +/ bool valid(string units)(int value) @safe pure nothrow - if (units == "months" || - units == "hours" || - units == "minutes" || - units == "seconds") +if (units == "months" || + units == "hours" || + units == "minutes" || + units == "seconds") { static if (units == "months") return value >= Month.jan && value <= Month.dec; @@ -33744,7 +33744,7 @@ bool valid(string units)(int value) @safe pure nothrow day = The day to validate. +/ bool valid(string units)(int year, int month, int day) @safe pure nothrow - if (units == "days") +if (units == "days") { return day > 0 && day <= maxDay(year, month); } @@ -33762,10 +33762,10 @@ bool valid(string units)(int year, int month, int day) @safe pure nothrow $(LREF DateTimeException) if $(D valid!units(value)) is false. +/ void enforceValid(string units)(int value, string file = __FILE__, size_t line = __LINE__) @safe pure - if (units == "months" || - units == "hours" || - units == "minutes" || - units == "seconds") +if (units == "months" || + units == "hours" || + units == "minutes" || + units == "seconds") { import std.format : format; @@ -33807,7 +33807,7 @@ void enforceValid(string units)(int value, string file = __FILE__, size_t line = +/ void enforceValid(string units) (int year, Month month, int day, string file = __FILE__, size_t line = __LINE__) @safe pure - if (units == "days") +if (units == "days") { import std.format : format; if (!valid!"days"(year, month, day)) @@ -34007,7 +34007,7 @@ static int daysToDayOfWeek(DayOfWeek currDoW, DayOfWeek dow) @safe pure nothrow $(LREF benchmark) +/ @safe auto measureTime(alias func)() - if (isSafe!((){StopWatch sw; unaryFun!func(sw.peek());})) +if (isSafe!((){StopWatch sw; unaryFun!func(sw.peek());})) { struct Result { @@ -34025,7 +34025,7 @@ static int daysToDayOfWeek(DayOfWeek currDoW, DayOfWeek dow) @safe pure nothrow } auto measureTime(alias func)() - if (!isSafe!((){StopWatch sw; unaryFun!func(sw.peek());})) +if (!isSafe!((){StopWatch sw; unaryFun!func(sw.peek());})) { struct Result { @@ -34163,7 +34163,7 @@ immutable string[12] _monthNames = ["Jan", Template to help with converting between time units. +/ template hnsecsPer(string units) - if (CmpTimeUnits!(units, "months") < 0) +if (CmpTimeUnits!(units, "months") < 0) { static if (units == "hnsecs") enum hnsecsPer = 1L; @@ -34198,8 +34198,8 @@ template hnsecsPer(string units) The number of the given units from converting hnsecs to those units. +/ long splitUnitsFromHNSecs(string units)(ref long hnsecs) @safe pure nothrow - if (validTimeUnits(units) && - CmpTimeUnits!(units, "months") < 0) +if (validTimeUnits(units) && + CmpTimeUnits!(units, "months") < 0) { immutable value = convert!("hnsecs", units)(hnsecs); hnsecs -= convert!(units, "hnsecs")(value); @@ -34235,8 +34235,8 @@ long splitUnitsFromHNSecs(string units)(ref long hnsecs) @safe pure nothrow The split out value. +/ long getUnitsFromHNSecs(string units)(long hnsecs) @safe pure nothrow - if (validTimeUnits(units) && - CmpTimeUnits!(units, "months") < 0) +if (validTimeUnits(units) && + CmpTimeUnits!(units, "months") < 0) { return convert!("hnsecs", units)(hnsecs); } @@ -34265,8 +34265,8 @@ long getUnitsFromHNSecs(string units)(long hnsecs) @safe pure nothrow The remaining hnsecs. +/ long removeUnitsFromHNSecs(string units)(long hnsecs) @safe pure nothrow - if (validTimeUnits(units) && - CmpTimeUnits!(units, "months") < 0) +if (validTimeUnits(units) && + CmpTimeUnits!(units, "months") < 0) { immutable value = convert!("hnsecs", units)(hnsecs); @@ -34522,8 +34522,8 @@ Month monthFromString(string monthStr) @safe pure The time units which are one step smaller than the given units. +/ template nextSmallerTimeUnits(string units) - if (validTimeUnits(units) && - timeStrings.front != units) +if (validTimeUnits(units) && + timeStrings.front != units) { import std.algorithm.searching : countUntil; enum nextSmallerTimeUnits = timeStrings[countUntil(timeStrings, units) - 1]; @@ -34548,8 +34548,8 @@ template nextSmallerTimeUnits(string units) The time units which are one step larger than the given units. +/ template nextLargerTimeUnits(string units) - if (validTimeUnits(units) && - timeStrings.back != units) +if (validTimeUnits(units) && + timeStrings.back != units) { import std.algorithm.searching : countUntil; enum nextLargerTimeUnits = timeStrings[countUntil(timeStrings, units) + 1]; @@ -34628,7 +34628,7 @@ static string fracSecsToISOString(int hnsecs) @safe pure nothrow fractional seconds. +/ static Duration fracSecsFromISOString(S)(in S isoString) @trusted pure - if (isSomeString!S) +if (isSomeString!S) { import std.algorithm.searching : all; import std.ascii : isDigit; @@ -34734,8 +34734,8 @@ static Duration fracSecsFromISOString(S)(in S isoString) @trusted pure Rather, it pops off the CFWS from the range and returns it. +/ R _stripCFWS(R)(R range) - if (isRandomAccessRange!R && hasSlicing!R && hasLength!R && - (is(Unqual!(ElementType!R) == char) || is(Unqual!(ElementType!R) == ubyte))) +if (isRandomAccessRange!R && hasSlicing!R && hasLength!R && + (is(Unqual!(ElementType!R) == char) || is(Unqual!(ElementType!R) == ubyte))) { immutable e = range.length; outer: for (size_t i = 0; i < e; ) @@ -34900,7 +34900,7 @@ R _stripCFWS(R)(R range) // doesn't have to worry about quite as many cases as std.conv.to, since it // doesn't have to worry about a sign on the value or about whether it fits. T _convDigits(T, R)(R str) - if (isIntegral!T && isSigned!T) // The constraints on R were already covered by parseRFC822DateTime. +if (isIntegral!T && isSigned!T) // The constraints on R were already covered by parseRFC822DateTime. { import std.ascii : isDigit; diff --git a/std/digest/crc.d b/std/digest/crc.d index a82b0443e..90faa3832 100644 --- a/std/digest/crc.d +++ b/std/digest/crc.d @@ -282,7 +282,8 @@ unittest { //Let's use the template features: //Note: When passing a CRC32 to a function, it must be passed by reference! - void doSomething(T)(ref T hash) if (isDigest!T) + void doSomething(T)(ref T hash) + if (isDigest!T) { hash.put(cast(ubyte)0); } diff --git a/std/digest/digest.d b/std/digest/digest.d index cad06107d..6c22dee35 100644 --- a/std/digest/digest.d +++ b/std/digest/digest.d @@ -92,7 +92,8 @@ unittest import std.stdio; // Digests a file and prints the result. - void digestFile(Hash)(string filename) if (isDigest!Hash) + void digestFile(Hash)(string filename) + if (isDigest!Hash) { auto file = File(filename); auto result = digest!Hash(file.byChunk(4096 * 1024)); @@ -116,7 +117,8 @@ unittest import std.digest.crc, std.digest.sha, std.digest.md; import std.stdio; // Digests a file and prints the result. - void digestFile(Hash)(ref Hash hash, string filename) if (isDigest!Hash) + void digestFile(Hash)(ref Hash hash, string filename) + if (isDigest!Hash) { File file = File(filename); @@ -303,7 +305,8 @@ unittest unittest { import std.digest.crc; - void myFunction(T)() if (isDigest!T) + void myFunction(T)() + if (isDigest!T) { T dig; dig.start(); @@ -377,7 +380,8 @@ unittest unittest { import std.digest.crc; - void myFunction(T)() if (hasPeek!T) + void myFunction(T)() + if (hasPeek!T) { T dig; dig.start(); @@ -424,7 +428,8 @@ package template isDigestibleRange(Range) * Params: * range= an $(D InputRange) with $(D ElementType) $(D ubyte), $(D ubyte[]) or $(D ubyte[num]) */ -DigestType!Hash digest(Hash, Range)(auto ref Range range) if (!isArray!Range +DigestType!Hash digest(Hash, Range)(auto ref Range range) +if (!isArray!Range && isDigestibleRange!Range) { import std.algorithm.mutation : copy; @@ -449,7 +454,8 @@ unittest * Params: * data= one or more arrays of any type */ -DigestType!Hash digest(Hash, T...)(scope const T data) if (allSatisfy!(isArray, typeof(data))) +DigestType!Hash digest(Hash, T...)(scope const T data) +if (allSatisfy!(isArray, typeof(data))) { Hash hash; hash.start(); @@ -486,7 +492,7 @@ unittest * range= an $(D InputRange) with $(D ElementType) $(D ubyte), $(D ubyte[]) or $(D ubyte[num]) */ char[digestLength!(Hash)*2] hexDigest(Hash, Order order = Order.increasing, Range)(ref Range range) - if (!isArray!Range && isDigestibleRange!Range) +if (!isArray!Range && isDigestibleRange!Range) { return toHexString!order(digest!Hash(range)); } @@ -508,7 +514,7 @@ unittest * data= one or more arrays of any type */ char[digestLength!(Hash)*2] hexDigest(Hash, Order order = Order.increasing, T...)(scope const T data) - if (allSatisfy!(isArray, typeof(data))) +if (allSatisfy!(isArray, typeof(data))) { return toHexString!order(digest!Hash(data)); } @@ -839,7 +845,8 @@ ref T[N] asArray(size_t N, T)(ref T[] source, string errorMsg = "") * useful for other purposes as well. It returns the length (in bytes) of the hash value * produced by T. */ -template digestLength(T) if (isDigest!T) +template digestLength(T) +if (isDigest!T) { enum size_t digestLength = (ReturnType!(T.finish)).length; } @@ -849,7 +856,8 @@ template digestLength(T) if (isDigest!T) * Modules providing digest implementations will usually provide * an alias for this template (e.g. MD5Digest, SHA1Digest, ...). */ -class WrapperDigest(T) if (isDigest!T) : Digest +class WrapperDigest(T) +if (isDigest!T) : Digest { protected: T _digest; diff --git a/std/digest/md.d b/std/digest/md.d index 07cce72a3..99f78db15 100644 --- a/std/digest/md.d +++ b/std/digest/md.d @@ -426,7 +426,8 @@ unittest unittest { //Let's use the template features: - void doSomething(T)(ref T hash) if (isDigest!T) + void doSomething(T)(ref T hash) + if (isDigest!T) { hash.put(cast(ubyte)0); } diff --git a/std/digest/ripemd.d b/std/digest/ripemd.d index 0514afab2..df8b07291 100644 --- a/std/digest/ripemd.d +++ b/std/digest/ripemd.d @@ -584,7 +584,8 @@ unittest unittest { //Let's use the template features: - void doSomething(T)(ref T hash) if (isDigest!T) + void doSomething(T)(ref T hash) + if (isDigest!T) { hash.put(cast(ubyte)0); } diff --git a/std/digest/sha.d b/std/digest/sha.d index 117707155..c3a23bde0 100644 --- a/std/digest/sha.d +++ b/std/digest/sha.d @@ -858,7 +858,8 @@ unittest { //Let's use the template features: //Note: When passing a SHA1 to a function, it must be passed by reference! - void doSomething(T)(ref T hash) if (isDigest!T) + void doSomething(T)(ref T hash) + if (isDigest!T) { hash.put(cast(ubyte)0); } diff --git a/std/encoding.d b/std/encoding.d index 427087b31..28efafb92 100644 --- a/std/encoding.d +++ b/std/encoding.d @@ -3501,7 +3501,7 @@ Returns: the found $(D BOMSeq) corresponding to the passed $(D input). */ immutable(BOMSeq) getBOM(Range)(Range input) - if (isForwardRange!Range && is(Unqual!(ElementType!Range) == ubyte)) +if (isForwardRange!Range && is(Unqual!(ElementType!Range) == ubyte)) { import std.algorithm.searching : startsWith; foreach (it; bomTable[1 .. $]) diff --git a/std/exception.d b/std/exception.d index 6c1063224..6c035af81 100644 --- a/std/exception.d +++ b/std/exception.d @@ -352,7 +352,8 @@ void assertThrown(T : Throwable = Exception, E) -------------------- +/ T enforce(E : Throwable = Exception, T)(T value, lazy const(char)[] msg = null, - string file = __FILE__, size_t line = __LINE__) if (is(typeof({ if (!value) {} }))) +string file = __FILE__, size_t line = __LINE__) +if (is(typeof({ if (!value) {} }))) { if (!value) bailOut!E(file, line, msg); return value; @@ -375,8 +376,8 @@ T enforce(E : Throwable = Exception, T)(T value, lazy const(char)[] msg = null, +/ T enforce(T, Dg, string file = __FILE__, size_t line = __LINE__) (T value, scope Dg dg) - if (isSomeFunction!Dg && is(typeof( dg() )) && - is(typeof({ if (!value) {} }))) +if (isSomeFunction!Dg && is(typeof( dg() )) && + is(typeof({ if (!value) {} }))) { if (!value) dg(); return value; @@ -576,7 +577,7 @@ T errnoEnforce(T, string file = __FILE__, size_t line = __LINE__) -------------------- +/ template enforceEx(E : Throwable) - if (is(typeof(new E("", __FILE__, __LINE__)))) +if (is(typeof(new E("", __FILE__, __LINE__)))) { /++ Ditto +/ T enforceEx(T)(T value, lazy string msg = "", string file = __FILE__, size_t line = __LINE__) @@ -588,7 +589,7 @@ template enforceEx(E : Throwable) /++ Ditto +/ template enforceEx(E : Throwable) - if (is(typeof(new E(__FILE__, __LINE__))) && !is(typeof(new E("", __FILE__, __LINE__)))) +if (is(typeof(new E(__FILE__, __LINE__))) && !is(typeof(new E("", __FILE__, __LINE__)))) { /++ Ditto +/ T enforceEx(T)(T value, string file = __FILE__, size_t line = __LINE__) @@ -1030,8 +1031,8 @@ as the language is free to assume objects don't have internal pointers (TDPL 7.1.3.5). */ bool doesPointTo(S, T, Tdummy=void)(auto ref const S source, ref const T target) @trusted pure nothrow - if (__traits(isRef, source) || isDynamicArray!S || - isPointer!S || is(S == class)) +if (__traits(isRef, source) || isDynamicArray!S || + isPointer!S || is(S == class)) { static if (isPointer!S || is(S == class) || is(S == interface)) { @@ -1073,8 +1074,8 @@ bool doesPointTo(S, T)(auto ref const shared S source, ref const shared T target /// ditto bool mayPointTo(S, T, Tdummy=void)(auto ref const S source, ref const T target) @trusted pure nothrow - if (__traits(isRef, source) || isDynamicArray!S || - isPointer!S || is(S == class)) +if (__traits(isRef, source) || isDynamicArray!S || + isPointer!S || is(S == class)) { static if (isPointer!S || is(S == class) || is(S == interface)) { @@ -1755,7 +1756,7 @@ this by $(D take)ing 0 from the return value of the handler function and returning that when an exception is caught. */ auto handle(E : Throwable, RangePrimitive primitivesToHandle, alias handler, Range)(Range input) - if (isInputRange!Range) +if (isInputRange!Range) { static struct Handler { diff --git a/std/experimental/allocator/building_blocks/segregator.d b/std/experimental/allocator/building_blocks/segregator.d index 6d42107d2..63530f1b3 100644 --- a/std/experimental/allocator/building_blocks/segregator.d +++ b/std/experimental/allocator/building_blocks/segregator.d @@ -317,7 +317,8 @@ to $(D A4). If some particular range should not be handled, $(D NullAllocator) may be used appropriately. */ -template Segregator(Args...) if (Args.length > 3) +template Segregator(Args...) +if (Args.length > 3) { // Binary search private enum cutPoint = ((Args.length - 2) / 4) * 2; diff --git a/std/experimental/logger/core.d b/std/experimental/logger/core.d index bab722744..5c3d1d0b0 100644 --- a/std/experimental/logger/core.d +++ b/std/experimental/logger/core.d @@ -114,7 +114,8 @@ If this module exists and it contains a $(D LogLevel) called logLevel this $(D LogLevel) will be used. This parent lookup is continued until there is no parent module. Then the moduleLogLevel is $(D LogLevel.all). */ -template moduleLogLevel(string moduleName) if (!moduleName.length) +template moduleLogLevel(string moduleName) +if (!moduleName.length) { // default enum moduleLogLevel = LogLevel.all; @@ -127,7 +128,8 @@ unittest } /// ditto -template moduleLogLevel(string moduleName) if (moduleName.length) +template moduleLogLevel(string moduleName) +if (moduleName.length) { import std.string : format; mixin(q{ @@ -165,7 +167,7 @@ $(LREF std.datatime.DateTime.toISOExtString) except the fractional second part. The fractional second part is in milliseconds and is always 3 digits. */ void systimeToISOString(OutputRange)(OutputRange o, const ref SysTime time) - if (isOutputRange!(OutputRange,string)) +if (isOutputRange!(OutputRange,string)) { import std.format : formattedWrite; @@ -197,7 +199,7 @@ void log(int line = __LINE__, string file = __FILE__, string funcName = __FUNCTION__, string prettyFuncName = __PRETTY_FUNCTION__, string moduleName = __MODULE__, A...)(const LogLevel ll, lazy bool condition, lazy A args) - if (args.length != 1) +if (args.length != 1) { static if (isLoggingActive) { @@ -241,7 +243,7 @@ log(LogLevel.warning, "Hello World", 3.1415); void log(int line = __LINE__, string file = __FILE__, string funcName = __FUNCTION__, string prettyFuncName = __PRETTY_FUNCTION__, string moduleName = __MODULE__, A...)(const LogLevel ll, lazy A args) - if (args.length > 1 && !is(Unqual!(A[0]) : bool)) +if (args.length > 1 && !is(Unqual!(A[0]) : bool)) { static if (isLoggingActive) { @@ -286,7 +288,7 @@ log(true, "Hello World", 3.1415); void log(int line = __LINE__, string file = __FILE__, string funcName = __FUNCTION__, string prettyFuncName = __PRETTY_FUNCTION__, string moduleName = __MODULE__, A...)(lazy bool condition, lazy A args) - if (args.length != 1) +if (args.length != 1) { static if (isLoggingActive) { @@ -323,9 +325,9 @@ log("Hello World", 3.1415); void log(int line = __LINE__, string file = __FILE__, string funcName = __FUNCTION__, string prettyFuncName = __PRETTY_FUNCTION__, string moduleName = __MODULE__, A...)(lazy A args) - if ((args.length > 1 && !is(Unqual!(A[0]) : bool) - && !is(Unqual!(A[0]) == LogLevel)) - || args.length == 0) +if ((args.length > 1 && !is(Unqual!(A[0]) : bool) + && !is(Unqual!(A[0]) == LogLevel)) + || args.length == 0) { static if (isLoggingActive) { diff --git a/std/experimental/ndslice/internal.d b/std/experimental/ndslice/internal.d index 602dda263..fb0c7e916 100644 --- a/std/experimental/ndslice/internal.d +++ b/std/experimental/ndslice/internal.d @@ -195,7 +195,7 @@ auto ptrShell(Range)(Range range, sizediff_t shift = 0) } private template PtrTupleFrontMembers(Names...) - if (Names.length <= 32) +if (Names.length <= 32) { static if (Names.length) { diff --git a/std/experimental/ndslice/iteration.d b/std/experimental/ndslice/iteration.d index 9e39bd8fe..4dd6f805e 100644 --- a/std/experimental/ndslice/iteration.d +++ b/std/experimental/ndslice/iteration.d @@ -410,7 +410,7 @@ Returns: See_also: $(LREF swapped), $(LREF everted) +/ template transposed(Dimensions...) - if (Dimensions.length) +if (Dimensions.length) { static if (!allSatisfy!(isSize_t, Dimensions)) alias transposed = .transposed!(staticMap!(toSize_t, Dimensions)); @@ -540,7 +540,7 @@ Returns: n-dimensional slice of the same type +/ template reversed(Dimensions...) - if (Dimensions.length) +if (Dimensions.length) { static if (!allSatisfy!(isSize_t, Dimensions)) alias reversed = .reversed!(staticMap!(toSize_t, Dimensions)); @@ -648,7 +648,7 @@ Returns: n-dimensional slice of the same type +/ template strided(Dimensions...) - if (Dimensions.length) +if (Dimensions.length) { static if (!allSatisfy!(isSize_t, Dimensions)) alias strided = .strided!(staticMap!(toSize_t, Dimensions)); @@ -877,7 +877,7 @@ Returns: n-dimensional slice of the same type +/ template dropOne(Dimensions...) - if (Dimensions.length) +if (Dimensions.length) { static if (!allSatisfy!(isSize_t, Dimensions)) alias dropOne = .dropOne!(staticMap!(toSize_t, Dimensions)); @@ -912,7 +912,7 @@ body ///ditto template dropBackOne(Dimensions...) - if (Dimensions.length) +if (Dimensions.length) { static if (!allSatisfy!(isSize_t, Dimensions)) alias dropBackOne = .dropBackOne!(staticMap!(toSize_t, Dimensions)); @@ -1002,7 +1002,7 @@ Returns: n-dimensional slice of the same type +/ template dropExactly(Dimensions...) - if (Dimensions.length) +if (Dimensions.length) { static if (!allSatisfy!(isSize_t, Dimensions)) alias dropExactly = .dropExactly!(staticMap!(toSize_t, Dimensions)); @@ -1033,7 +1033,7 @@ body ///ditto template dropBackExactly(Dimensions...) - if (Dimensions.length) +if (Dimensions.length) { static if (!allSatisfy!(isSize_t, Dimensions)) alias dropBackExactly = .dropBackExactly!(staticMap!(toSize_t, Dimensions)); @@ -1098,7 +1098,7 @@ Returns: n-dimensional slice of the same type +/ template drop(Dimensions...) - if (Dimensions.length) +if (Dimensions.length) { static if (!allSatisfy!(isSize_t, Dimensions)) alias drop = .drop!(staticMap!(toSize_t, Dimensions)); @@ -1129,7 +1129,7 @@ body ///ditto template dropBack(Dimensions...) - if (Dimensions.length) +if (Dimensions.length) { static if (!allSatisfy!(isSize_t, Dimensions)) alias dropBack = .dropBack!(staticMap!(toSize_t, Dimensions)); diff --git a/std/experimental/ndslice/selection.d b/std/experimental/ndslice/selection.d index 754315c48..212a6ecb3 100644 --- a/std/experimental/ndslice/selection.d +++ b/std/experimental/ndslice/selection.d @@ -1811,7 +1811,7 @@ Slice composed of indexes. See_also: $(LREF indexSlice) +/ template IndexSlice(size_t N) - if (N) +if (N) { struct IndexMap { @@ -1915,7 +1915,7 @@ Slice composed of flattened indexes. See_also: $(LREF iotaSlice) +/ template IotaSlice(size_t N) - if (N) +if (N) { alias IotaSlice = Slice!(N, IotaMap!()); } @@ -1943,7 +1943,7 @@ Returns: See_also: $(REF repeat, std,range) +/ RepeatSlice!(M, T) repeatSlice(T, size_t M)(T value, size_t[M] lengths...) - if (!is(T : Slice!(N, Range), size_t N, Range)) +if (!is(T : Slice!(N, Range), size_t N, Range)) { typeof(return) ret; foreach (i; Iota!(0, ret.N)) @@ -2027,7 +2027,7 @@ pure nothrow unittest Slice composed of identical values. +/ template RepeatSlice(size_t N, T) - if (N) +if (N) { alias RepeatSlice = Slice!(N, RepeatPtr!T); } @@ -2105,7 +2105,7 @@ See_Also: $(HTTP en.wikipedia.org/wiki/Map_(higher-order_function), Map (higher-order function)) +/ template mapSlice(fun...) - if (fun.length) +if (fun.length) { /// @fmb auto mapSlice(size_t N, Range) diff --git a/std/experimental/ndslice/slice.d b/std/experimental/ndslice/slice.d index 0e59d3d44..4e2cd9569 100644 --- a/std/experimental/ndslice/slice.d +++ b/std/experimental/ndslice/slice.d @@ -53,7 +53,7 @@ auto sliced( Flag!"replaceArrayWithPointer" ra = Yes.replaceArrayWithPointer, Flag!"allowDownsize" ad = No.allowDownsize, Range, size_t N)(Range range, size_t[N] lengths...) - if (!isStaticArray!Range && !isNarrowString!Range && N) +if (!isStaticArray!Range && !isNarrowString!Range && N) { return .sliced!(ra, ad)(range, lengths, 0); } @@ -63,7 +63,7 @@ auto sliced( Flag!"replaceArrayWithPointer" ra = Yes.replaceArrayWithPointer, Flag!"allowDownsize" ad = No.allowDownsize, size_t N, Range)(Range range, size_t[N] lengths, size_t shift = 0) - if (!isStaticArray!Range && !isNarrowString!Range && N) +if (!isStaticArray!Range && !isNarrowString!Range && N) in { static if (hasLength!Range) @@ -140,7 +140,7 @@ private enum bool _isSlice(T) = is(T : Slice!(N, Range), size_t N, Range); ///ditto template sliced(Names...) - if (Names.length && !anySatisfy!(isType, Names) && allSatisfy!(isStringValue, Names)) +if (Names.length && !anySatisfy!(isType, Names) && allSatisfy!(isStringValue, Names)) { mixin ( " @@ -216,7 +216,7 @@ auto sliced( Flag!"replaceArrayWithPointer" ra = Yes.replaceArrayWithPointer, Flag!"allowDownsize" ad = No.allowDownsize, Range)(Range range) - if (!isStaticArray!Range && !isNarrowString!Range && hasLength!Range) +if (!isStaticArray!Range && !isNarrowString!Range && hasLength!Range) { return .sliced!(ra, ad, 1, Range)(range, [range.length]); } @@ -433,7 +433,7 @@ Returns: See_also: $(LREF .Slice.structure). +/ template assumeSameStructure(Names...) - if (Names.length && !anySatisfy!(isType, Names) && allSatisfy!(isStringValue, Names)) +if (Names.length && !anySatisfy!(isType, Names) && allSatisfy!(isStringValue, Names)) { mixin ( " @@ -1264,9 +1264,9 @@ r______________reversed!1 ------- +/ struct Slice(size_t _N, _Range) - if (_N && _N < 256LU && ((!is(Unqual!_Range : Slice!(N0, Range0), size_t N0, Range0) - && (isPointer!_Range || is(typeof(_Range.init[size_t.init])))) - || is(_Range == Slice!(N1, Range1), size_t N1, Range1))) +if (_N && _N < 256LU && ((!is(Unqual!_Range : Slice!(N0, Range0), size_t N0, Range0) + && (isPointer!_Range || is(typeof(_Range.init[size_t.init])))) + || is(_Range == Slice!(N1, Range1), size_t N1, Range1))) { @fmb: @@ -3304,7 +3304,7 @@ private void opIndexAssignImpl( size_t NR, RangeR)( Slice!(NL, RangeL) ls, Slice!(NR, RangeR) rs) - if (NL >= NR) +if (NL >= NR) { assert(_checkAssignLengths(ls, rs), __FUNCTION__ ~ ": arguments must have the corresponding shape."); @@ -3351,7 +3351,7 @@ pure nothrow unittest private void opIndexAssignImpl (string op, size_t NL, RangeL, T)( Slice!(NL, RangeL) ls, T rs) - if (!is(T : Slice!(NR, RangeR), size_t NR, RangeR)) +if (!is(T : Slice!(NR, RangeR), size_t NR, RangeR)) { foreach (i; Iota!(0, ls.PureN)) if (ls._lengths[i] == 0) @@ -3480,7 +3480,7 @@ private void _indexAssignValKernel(string op, TL, TR)(size_t c, TL l, TR r) private void _indexAssign(bool lastStrideEquals1, string op, size_t NL, RangeL, size_t NR, RangeR) (Slice!(NL, RangeL) ls, Slice!(NR, RangeR) rs) - if (NL >= NR) +if (NL >= NR) { static if (NL == 1) { @@ -3525,7 +3525,7 @@ private void _indexAssign(bool lastStrideEquals1, string op, size_t NL, RangeL, } private void _indexAssign(bool lastStrideEquals1, string op, size_t NL, RangeL, T)(Slice!(NL, RangeL) ls, T[] rs) - if (DynamicArrayDimensionsCount!(T[]) <= NL) +if (DynamicArrayDimensionsCount!(T[]) <= NL) { assert(ls.length == rs.length, __FUNCTION__ ~ ": argument must have the same length."); static if (NL == 1) @@ -3571,8 +3571,8 @@ private void _indexAssign(bool lastStrideEquals1, string op, size_t NL, RangeL, } private void _indexAssign(bool lastStrideEquals1, string op, size_t NL, RangeL, T)(Slice!(NL, RangeL) ls, T rs) - if ((!isDynamicArray!T || isDynamicArray!(Slice!(NL, RangeL).DeepElemType)) - && !is(T : Slice!(NR, RangeR), size_t NR, RangeR)) +if ((!isDynamicArray!T || isDynamicArray!(Slice!(NL, RangeL).DeepElemType)) + && !is(T : Slice!(NR, RangeR), size_t NR, RangeR)) { static if (NL == 1) { @@ -3605,7 +3605,7 @@ private void _indexAssign(bool lastStrideEquals1, string op, size_t NL, RangeL, } private bool _checkAssignLengths(size_t NL, RangeL, size_t NR, RangeR)(Slice!(NL, RangeL) ls, Slice!(NR, RangeR) rs) - if (NL >= NR) +if (NL >= NR) { foreach (i; Iota!(0, NR)) if (ls._lengths[i + NL - NR] != rs._lengths[i]) diff --git a/std/file.d b/std/file.d index dbaf85691..7e8fb5dcc 100644 --- a/std/file.d +++ b/std/file.d @@ -233,8 +233,8 @@ Throws: $(LREF FileException) on error. */ void[] read(R)(R name, size_t upTo = size_t.max) - if (isInputRange!R && isSomeChar!(ElementEncodingType!R) && !isInfinite!R && - !isConvertibleToString!R) +if (isInputRange!R && isSomeChar!(ElementEncodingType!R) && !isInfinite!R && + !isConvertibleToString!R) { static if (isNarrowString!R && is(Unqual!(ElementEncodingType!R) == char)) return readImpl(name, name.tempCString!FSChar(), upTo); @@ -259,7 +259,7 @@ void[] read(R)(R name, size_t upTo = size_t.max) } void[] read(R)(auto ref R name, size_t upTo = size_t.max) - if (isConvertibleToString!R) +if (isConvertibleToString!R) { return read!(StringTypeOf!R)(name, upTo); } @@ -419,9 +419,9 @@ decoding error. */ S readText(S = string, R)(R name) - if (isSomeString!S && - (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) || isSomeString!R) && - !isConvertibleToString!R) +if (isSomeString!S && + (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) || isSomeString!R) && + !isConvertibleToString!R) { import std.utf : validate; static auto trustedCast(void[] buf) @trusted { return cast(S)buf; } @@ -441,7 +441,7 @@ S readText(S = string, R)(R name) } S readText(S = string, R)(auto ref R name) - if (isConvertibleToString!R) +if (isConvertibleToString!R) { return readText!(S, StringTypeOf!R)(name); } @@ -463,8 +463,8 @@ Throws: $(D FileException) on error. See_also: $(REF toFile, std,stdio) */ void write(R)(R name, const void[] buffer) - if ((isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) || isSomeString!R) && - !isConvertibleToString!R) +if ((isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) || isSomeString!R) && + !isConvertibleToString!R) { static if (isNarrowString!R && is(Unqual!(ElementEncodingType!R) == char)) writeImpl(name, name.tempCString!FSChar(), buffer, false); @@ -487,7 +487,7 @@ void write(R)(R name, const void[] buffer) } void write(R)(auto ref R name, const void[] buffer) - if (isConvertibleToString!R) +if (isConvertibleToString!R) { write!(StringTypeOf!R)(name, buffer); } @@ -507,8 +507,8 @@ Params: Throws: $(D FileException) on error. */ void append(R)(R name, const void[] buffer) - if ((isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) || isSomeString!R) && - !isConvertibleToString!R) +if ((isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) || isSomeString!R) && + !isConvertibleToString!R) { static if (isNarrowString!R && is(Unqual!(ElementEncodingType!R) == char)) writeImpl(name, name.tempCString!FSChar(), buffer, true); @@ -533,7 +533,7 @@ void append(R)(R name, const void[] buffer) } void append(R)(auto ref R name, const void[] buffer) - if (isConvertibleToString!R) +if (isConvertibleToString!R) { append!(StringTypeOf!R)(name, buffer); } @@ -625,10 +625,10 @@ version(Windows) private void writeImpl(const(char)[] name, const(FSChar)* namez * Throws: $(D FileException) on error. */ void rename(RF, RT)(RF from, RT to) - if ((isInputRange!RF && !isInfinite!RF && isSomeChar!(ElementEncodingType!RF) || isSomeString!RF) - && !isConvertibleToString!RF && - (isInputRange!RT && !isInfinite!RT && isSomeChar!(ElementEncodingType!RT) || isSomeString!RT) - && !isConvertibleToString!RT) +if ((isInputRange!RF && !isInfinite!RF && isSomeChar!(ElementEncodingType!RF) || isSomeString!RF) + && !isConvertibleToString!RF && + (isInputRange!RT && !isInfinite!RT && isSomeChar!(ElementEncodingType!RT) || isSomeString!RT) + && !isConvertibleToString!RT) { // Place outside of @trusted block auto fromz = from.tempCString!FSChar(); @@ -648,7 +648,7 @@ void rename(RF, RT)(RF from, RT to) } void rename(RF, RT)(auto ref RF from, auto ref RT to) - if (isConvertibleToString!RF || isConvertibleToString!RT) +if (isConvertibleToString!RF || isConvertibleToString!RT) { import std.meta : staticMap; alias Types = staticMap!(convertToString, RF, RT); @@ -719,8 +719,8 @@ Params: Throws: $(D FileException) on error. */ void remove(R)(R name) - if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) && - !isConvertibleToString!R) +if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) && + !isConvertibleToString!R) { static if (isNarrowString!R && is(Unqual!(ElementEncodingType!R) == char)) removeImpl(name, name.tempCString!FSChar()); @@ -729,7 +729,7 @@ void remove(R)(R name) } void remove(R)(auto ref R name) - if (isConvertibleToString!R) +if (isConvertibleToString!R) { remove!(StringTypeOf!R)(name); } @@ -761,7 +761,7 @@ private void removeImpl(const(char)[] name, const(FSChar)* namez) @trusted } version(Windows) private WIN32_FILE_ATTRIBUTE_DATA getFileAttributesWin(R)(R name) - if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R)) +if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R)) { auto namez = name.tempCString!FSChar(); @@ -810,8 +810,8 @@ Params: Throws: $(D FileException) on error (e.g., file not found). */ ulong getSize(R)(R name) - if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) && - !isConvertibleToString!R) +if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) && + !isConvertibleToString!R) { version(Windows) { @@ -837,7 +837,7 @@ ulong getSize(R)(R name) } ulong getSize(R)(auto ref R name) - if (isConvertibleToString!R) +if (isConvertibleToString!R) { return getSize!(StringTypeOf!R)(name); } @@ -896,8 +896,8 @@ private SysTime statTimeToStdTime(char which)(ref stat_t statbuf) void getTimes(R)(R name, out SysTime accessTime, out SysTime modificationTime) - if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) && - !isConvertibleToString!R) +if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) && + !isConvertibleToString!R) { version(Windows) { @@ -931,7 +931,7 @@ void getTimes(R)(R name, void getTimes(R)(auto ref R name, out SysTime accessTime, out SysTime modificationTime) - if (isConvertibleToString!R) +if (isConvertibleToString!R) { return getTimes!(StringTypeOf!R)(name, accessTime, modificationTime); } @@ -1020,8 +1020,8 @@ version(StdDdoc) out SysTime fileCreationTime, out SysTime fileAccessTime, out SysTime fileModificationTime) - if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) && - !isConvertibleToString!R); + if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) && + !isConvertibleToString!R); } else version(Windows) { @@ -1029,8 +1029,8 @@ else version(Windows) out SysTime fileCreationTime, out SysTime fileAccessTime, out SysTime fileModificationTime) - if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) && - !isConvertibleToString!R) + if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) && + !isConvertibleToString!R) { with (getFileAttributesWin(name)) { @@ -1044,7 +1044,7 @@ else version(Windows) out SysTime fileCreationTime, out SysTime fileAccessTime, out SysTime fileModificationTime) - if (isConvertibleToString!R) + if (isConvertibleToString!R) { getTimesWin!(StringTypeOf!R)(name, fileCreationTime, fileAccessTime, fileModificationTime); } @@ -1135,8 +1135,8 @@ version(Windows) @system unittest void setTimes(R)(R name, SysTime accessTime, SysTime modificationTime) - if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) && - !isConvertibleToString!R) +if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) && + !isConvertibleToString!R) { version(Windows) { @@ -1227,7 +1227,7 @@ void setTimes(R)(R name, void setTimes(R)(auto ref R name, SysTime accessTime, SysTime modificationTime) - if (isConvertibleToString!R) +if (isConvertibleToString!R) { setTimes!(StringTypeOf!R)(name, accessTime, modificationTime); } @@ -1278,8 +1278,8 @@ void setTimes(R)(auto ref R name, $(D FileException) if the given file does not exist. +/ SysTime timeLastModified(R)(R name) - if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) && - !isConvertibleToString!R) +if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) && + !isConvertibleToString!R) { version(Windows) { @@ -1310,7 +1310,7 @@ SysTime timeLastModified(R)(R name) } SysTime timeLastModified(R)(auto ref R name) - if (isConvertibleToString!R) +if (isConvertibleToString!R) { return timeLastModified!(StringTypeOf!R)(name); } @@ -1351,7 +1351,7 @@ else -------------------- +/ SysTime timeLastModified(R)(R name, SysTime returnIfMissing) - if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R)) +if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R)) { version(Windows) { @@ -1437,14 +1437,14 @@ version (OSX) {} else * true if the filename specified as input exists */ bool exists(R)(R name) - if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) && - !isConvertibleToString!R) +if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) && + !isConvertibleToString!R) { return existsImpl(name.tempCString!FSChar()); } bool exists(R)(auto ref R name) - if (isConvertibleToString!R) +if (isConvertibleToString!R) { return exists!(StringTypeOf!R)(name); } @@ -1522,8 +1522,8 @@ private bool existsImpl(const(FSChar)* namez) @trusted nothrow @nogc Throws: $(D FileException) on error. +/ uint getAttributes(R)(R name) - if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) && - !isConvertibleToString!R) +if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) && + !isConvertibleToString!R) { version(Windows) { @@ -1562,7 +1562,7 @@ uint getAttributes(R)(R name) } uint getAttributes(R)(auto ref R name) - if (isConvertibleToString!R) +if (isConvertibleToString!R) { return getAttributes!(StringTypeOf!R)(name); } @@ -1592,8 +1592,8 @@ uint getAttributes(R)(auto ref R name) $(D FileException) on error. +/ uint getLinkAttributes(R)(R name) - if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) && - !isConvertibleToString!R) +if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) && + !isConvertibleToString!R) { version(Windows) { @@ -1617,7 +1617,7 @@ uint getLinkAttributes(R)(R name) } uint getLinkAttributes(R)(auto ref R name) - if (isConvertibleToString!R) +if (isConvertibleToString!R) { return getLinkAttributes!(StringTypeOf!R)(name); } @@ -1638,8 +1638,8 @@ uint getLinkAttributes(R)(auto ref R name) $(D FileException) if the given file does not exist. +/ void setAttributes(R)(R name, uint attributes) - if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) && - !isConvertibleToString!R) +if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) && + !isConvertibleToString!R) { version (Windows) { @@ -1671,7 +1671,7 @@ void setAttributes(R)(R name, uint attributes) } void setAttributes(R)(auto ref R name, uint attributes) - if (isConvertibleToString!R) +if (isConvertibleToString!R) { return setAttributes!(StringTypeOf!R)(name, attributes); } @@ -1700,8 +1700,8 @@ assert("/usr/share/include".isDir); -------------------- +/ @property bool isDir(R)(R name) - if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) && - !isConvertibleToString!R) +if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) && + !isConvertibleToString!R) { version(Windows) { @@ -1714,7 +1714,7 @@ assert("/usr/share/include".isDir); } @property bool isDir(R)(auto ref R name) - if (isConvertibleToString!R) +if (isConvertibleToString!R) { return name.isDir!(StringTypeOf!R); } @@ -1850,8 +1850,8 @@ assert(!"/usr/share/include".isFile); -------------------- +/ @property bool isFile(R)(R name) - if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) && - !isConvertibleToString!R) +if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) && + !isConvertibleToString!R) { version(Windows) return !name.isDir; @@ -1860,7 +1860,7 @@ assert(!"/usr/share/include".isFile); } @property bool isFile(R)(auto ref R name) - if (isConvertibleToString!R) +if (isConvertibleToString!R) { return isFile!(StringTypeOf!R)(name); } @@ -1984,8 +1984,8 @@ bool attrIsFile(uint attributes) @safe pure nothrow @nogc $(D FileException) if the given file does not exist. +/ @property bool isSymlink(R)(R name) - if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) && - !isConvertibleToString!R) +if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) && + !isConvertibleToString!R) { version(Windows) return (getAttributes(name) & FILE_ATTRIBUTE_REPARSE_POINT) != 0; @@ -1994,7 +1994,7 @@ bool attrIsFile(uint attributes) @safe pure nothrow @nogc } @property bool isSymlink(R)(auto ref R name) - if (isConvertibleToString!R) +if (isConvertibleToString!R) { return name.isSymlink!(StringTypeOf!R); } @@ -2112,8 +2112,8 @@ bool attrIsSymlink(uint attributes) @safe pure nothrow @nogc * Throws: $(D FileException) on error. */ void chdir(R)(R pathname) - if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) && - !isConvertibleToString!R) +if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) && + !isConvertibleToString!R) { // Place outside of @trusted block auto pathz = pathname.tempCString!FSChar(); @@ -2140,7 +2140,7 @@ void chdir(R)(R pathname) } void chdir(R)(auto ref R pathname) - if (isConvertibleToString!R) +if (isConvertibleToString!R) { return chdir!(StringTypeOf!R)(pathname); } @@ -2157,8 +2157,8 @@ Throws: $(D FileException) on Posix or $(D WindowsException) on Windows if an error occured. */ void mkdir(R)(R pathname) - if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) && - !isConvertibleToString!R) +if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) && + !isConvertibleToString!R) { // Place outside of @trusted block auto pathz = pathname.tempCString!FSChar(); @@ -2192,7 +2192,7 @@ void mkdir(R)(R pathname) } void mkdir(R)(auto ref R pathname) - if (isConvertibleToString!R) +if (isConvertibleToString!R) { return mkdir!(StringTypeOf!R)(pathname); } @@ -2308,8 +2308,8 @@ Params: Throws: $(D FileException) on error. */ void rmdir(R)(R pathname) - if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) && - !isConvertibleToString!R) +if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) && + !isConvertibleToString!R) { // Place outside of @trusted block auto pathz = pathname.tempCString!FSChar(); @@ -2336,7 +2336,7 @@ void rmdir(R)(R pathname) } void rmdir(R)(auto ref R pathname) - if (isConvertibleToString!R) +if (isConvertibleToString!R) { rmdir!(StringTypeOf!R)(pathname); } @@ -2363,15 +2363,15 @@ void rmdir(R)(auto ref R pathname) exists). +/ version(StdDdoc) void symlink(RO, RL)(RO original, RL link) - if ((isInputRange!RO && !isInfinite!RO && isSomeChar!(ElementEncodingType!RO) || - isConvertibleToString!RO) && - (isInputRange!RL && !isInfinite!RL && isSomeChar!(ElementEncodingType!RL) || - isConvertibleToString!RL)); +if ((isInputRange!RO && !isInfinite!RO && isSomeChar!(ElementEncodingType!RO) || + isConvertibleToString!RO) && + (isInputRange!RL && !isInfinite!RL && isSomeChar!(ElementEncodingType!RL) || + isConvertibleToString!RL)); else version(Posix) void symlink(RO, RL)(RO original, RL link) - if ((isInputRange!RO && !isInfinite!RO && isSomeChar!(ElementEncodingType!RO) || - isConvertibleToString!RO) && - (isInputRange!RL && !isInfinite!RL && isSomeChar!(ElementEncodingType!RL) || - isConvertibleToString!RL)) +if ((isInputRange!RO && !isInfinite!RO && isSomeChar!(ElementEncodingType!RO) || + isConvertibleToString!RO) && + (isInputRange!RL && !isInfinite!RL && isSomeChar!(ElementEncodingType!RL) || + isConvertibleToString!RL)) { static if (isConvertibleToString!RO || isConvertibleToString!RL) { @@ -2452,11 +2452,11 @@ version(Posix) @safe unittest $(D FileException) on error. +/ version(StdDdoc) string readLink(R)(R link) - if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) || - isConvertibleToString!R); +if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) || + isConvertibleToString!R); else version(Posix) string readLink(R)(R link) - if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) || - isConvertibleToString!R) +if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) || + isConvertibleToString!R) { static if (isConvertibleToString!R) { @@ -3298,8 +3298,8 @@ Params: Throws: $(D FileException) on error. */ void copy(RF, RT)(RF from, RT to, PreserveAttributes preserve = preserveAttributesDefault) - if (isInputRange!RF && !isInfinite!RF && isSomeChar!(ElementEncodingType!RF) && !isConvertibleToString!RF && - isInputRange!RT && !isInfinite!RT && isSomeChar!(ElementEncodingType!RT) && !isConvertibleToString!RT) +if (isInputRange!RF && !isInfinite!RF && isSomeChar!(ElementEncodingType!RF) && !isConvertibleToString!RF && + isInputRange!RT && !isInfinite!RT && isSomeChar!(ElementEncodingType!RT) && !isConvertibleToString!RT) { // Place outside of @trusted block auto fromz = from.tempCString!FSChar(); @@ -3319,7 +3319,7 @@ void copy(RF, RT)(RF from, RT to, PreserveAttributes preserve = preserveAttribut } void copy(RF, RT)(auto ref RF from, auto ref RT to, PreserveAttributes preserve = preserveAttributesDefault) - if (isConvertibleToString!RF || isConvertibleToString!RT) +if (isConvertibleToString!RF || isConvertibleToString!RT) { import std.meta : staticMap; alias Types = staticMap!(convertToString, RF, RT); diff --git a/std/format.d b/std/format.d index d638494a7..88d5d1ca7 100644 --- a/std/format.d +++ b/std/format.d @@ -858,7 +858,7 @@ if (allSatisfy!(isPointer, S)) } template FormatSpec(Char) - if (!is(Unqual!Char == Char)) +if (!is(Unqual!Char == Char)) { alias FormatSpec = FormatSpec!(Unqual!Char); } @@ -868,7 +868,7 @@ template FormatSpec(Char) * specific formatting functions. */ struct FormatSpec(Char) - if (is(Unqual!Char == Char)) +if (is(Unqual!Char == Char)) { import std.ascii : isDigit; import std.algorithm.searching : startsWith; @@ -3662,7 +3662,7 @@ if (isPointer!T && !is(T == enum) && !hasToString!(T, Char)) Delegates are formatted by 'ReturnType delegate(Parameters) FunctionAttributes' */ void formatValue(Writer, T, Char)(Writer w, scope T, ref FormatSpec!Char f) - if (isDelegate!T) +if (isDelegate!T) { formatValue(w, T.stringof, f); } @@ -4528,7 +4528,7 @@ private template acceptedSpecs(T) * $(REF parse, std, conv) and $(REF to, std, conv) */ T unformatValue(T, Range, Char)(ref Range input, ref FormatSpec!Char spec) - if (isInputRange!Range && is(Unqual!T == bool)) +if (isInputRange!Range && is(Unqual!T == bool)) { import std.algorithm.searching : find; import std.conv : parse, text; @@ -4543,7 +4543,7 @@ T unformatValue(T, Range, Char)(ref Range input, ref FormatSpec!Char spec) /// ditto T unformatValue(T, Range, Char)(ref Range input, ref FormatSpec!Char spec) - if (isInputRange!Range && is(T == typeof(null))) +if (isInputRange!Range && is(T == typeof(null))) { import std.conv : parse, text; enforce(spec.spec == 's', @@ -4554,7 +4554,7 @@ T unformatValue(T, Range, Char)(ref Range input, ref FormatSpec!Char spec) /// ditto T unformatValue(T, Range, Char)(ref Range input, ref FormatSpec!Char spec) - if (isInputRange!Range && isIntegral!T && !is(T == enum) && isSomeChar!(ElementType!Range)) +if (isInputRange!Range && isIntegral!T && !is(T == enum) && isSomeChar!(ElementType!Range)) { import std.algorithm.searching : find; @@ -4588,8 +4588,8 @@ T unformatValue(T, Range, Char)(ref Range input, ref FormatSpec!Char spec) /// ditto T unformatValue(T, Range, Char)(ref Range input, ref FormatSpec!Char spec) - if (isFloatingPoint!T && !is(T == enum) && isInputRange!Range - && isSomeChar!(ElementType!Range)&& !is(Range == enum)) +if (isFloatingPoint!T && !is(T == enum) && isInputRange!Range + && isSomeChar!(ElementType!Range)&& !is(Range == enum)) { import std.algorithm.searching : find; import std.conv : parse, text; @@ -4612,7 +4612,7 @@ T unformatValue(T, Range, Char)(ref Range input, ref FormatSpec!Char spec) /// ditto T unformatValue(T, Range, Char)(ref Range input, ref FormatSpec!Char spec) - if (isInputRange!Range && isSomeChar!T && !is(T == enum) && isSomeChar!(ElementType!Range)) +if (isInputRange!Range && isSomeChar!T && !is(T == enum) && isSomeChar!(ElementType!Range)) { import std.algorithm.searching : find; import std.conv : to, text; @@ -4637,7 +4637,7 @@ T unformatValue(T, Range, Char)(ref Range input, ref FormatSpec!Char spec) /// ditto T unformatValue(T, Range, Char)(ref Range input, ref FormatSpec!Char spec) - if (isInputRange!Range && is(StringTypeOf!T) && !isAggregateType!T && !is(T == enum)) +if (isInputRange!Range && is(StringTypeOf!T) && !isAggregateType!T && !is(T == enum)) { import std.conv : text; @@ -4690,7 +4690,7 @@ T unformatValue(T, Range, Char)(ref Range input, ref FormatSpec!Char spec) /// ditto T unformatValue(T, Range, Char)(ref Range input, ref FormatSpec!Char spec) - if (isInputRange!Range && isArray!T && !is(StringTypeOf!T) && !isAggregateType!T && !is(T == enum)) +if (isInputRange!Range && isArray!T && !is(StringTypeOf!T) && !isAggregateType!T && !is(T == enum)) { import std.conv : parse, text; if (spec.spec == '(') @@ -4705,7 +4705,7 @@ T unformatValue(T, Range, Char)(ref Range input, ref FormatSpec!Char spec) /// ditto T unformatValue(T, Range, Char)(ref Range input, ref FormatSpec!Char spec) - if (isInputRange!Range && isAssociativeArray!T && !is(T == enum)) +if (isInputRange!Range && isAssociativeArray!T && !is(T == enum)) { import std.conv : parse, text; if (spec.spec == '(') @@ -4830,9 +4830,9 @@ T unformatValue(T, Range, Char)(ref Range input, ref FormatSpec!Char spec) * for integral and float types. */ private T rawRead(T, Range)(ref Range input) - if (is(Unqual!(ElementEncodingType!Range) == char) - || is(Unqual!(ElementEncodingType!Range) == byte) - || is(Unqual!(ElementEncodingType!Range) == ubyte)) +if (is(Unqual!(ElementEncodingType!Range) == char) + || is(Unqual!(ElementEncodingType!Range) == byte) + || is(Unqual!(ElementEncodingType!Range) == ubyte)) { union X { @@ -4961,7 +4961,7 @@ body // Undocumented T unformatElement(T, Range, Char)(ref Range input, ref FormatSpec!Char spec) - if (isInputRange!Range) +if (isInputRange!Range) { import std.conv : parseElement; static if (isSomeString!T) @@ -5408,7 +5408,8 @@ private bool needToSwapEndianess(Char)(ref FormatSpec!Char f) * Params: fmt = Format string. For detailed specification, see $(REF formattedWrite, std,_format). * args = Variadic list of arguments to format into returned string. */ -immutable(Char)[] format(Char, Args...)(in Char[] fmt, Args args) if (isSomeChar!Char) +immutable(Char)[] format(Char, Args...)(in Char[] fmt, Args args) +if (isSomeChar!Char) { import std.format : formattedWrite, FormatException; import std.array : appender; diff --git a/std/functional.d b/std/functional.d index bfed01c9f..dff0ab515 100644 --- a/std/functional.d +++ b/std/functional.d @@ -417,7 +417,7 @@ private uint _ctfeMatchBinary(string fun, string name1, string name2) //undocumented template safeOp(string S) - if (S=="<"||S==">"||S=="<="||S==">="||S=="=="||S=="!=") +if (S=="<"||S==">"||S=="<="||S==">="||S=="=="||S=="!=") { import std.traits : isIntegral; private bool unsafeOp(ElementType1, ElementType2)(ElementType1 a, ElementType2 b) pure @@ -795,12 +795,14 @@ Note: In the special case where only a single function is provided ($(D F.length == 1)), adjoin simply aliases to the single passed function ($(D F[0])). */ -template adjoin(F...) if (F.length == 1) +template adjoin(F...) +if (F.length == 1) { alias adjoin = F[0]; } /// ditto -template adjoin(F...) if (F.length > 1) +template adjoin(F...) +if (F.length > 1) { auto adjoin(V...)(auto ref V a) { @@ -1245,7 +1247,8 @@ private struct DelegateFaker(F) * $(LI Ignores C-style / D-style variadic arguments.) * ) */ -auto toDelegate(F)(auto ref F fp) if (isCallable!(F)) +auto toDelegate(F)(auto ref F fp) +if (isCallable!(F)) { static if (is(F == delegate)) { diff --git a/std/internal/cstring.d b/std/internal/cstring.d index 8a0254835..9bf4cc2ae 100644 --- a/std/internal/cstring.d +++ b/std/internal/cstring.d @@ -87,8 +87,8 @@ See $(RED WARNING) in $(B Examples) section. */ auto tempCString(To = char, From)(From str) - if (isSomeChar!To && (isInputRange!From || isSomeString!From) && - isSomeChar!(ElementEncodingType!From)) +if (isSomeChar!To && (isInputRange!From || isSomeString!From) && + isSomeChar!(ElementEncodingType!From)) { alias CF = Unqual!(ElementEncodingType!From); diff --git a/std/internal/math/biguintcore.d b/std/internal/math/biguintcore.d index 9b9c7c161..99d7bbdec 100644 --- a/std/internal/math/biguintcore.d +++ b/std/internal/math/biguintcore.d @@ -78,7 +78,8 @@ else static assert(0, "Unsupported BigDigit size"); private import std.exception : assumeUnique; private import std.traits : isIntegral; enum BigDigitBits = BigDigit.sizeof*8; -template maxBigDigits(T) if (isIntegral!T) +template maxBigDigits(T) +if (isIntegral!T) { enum maxBigDigits = (T.sizeof+BigDigit.sizeof-1)/BigDigit.sizeof; } @@ -1692,7 +1693,8 @@ size_t biguintToDecimal(char [] buff, BigDigit [] data) pure nothrow * Returns: * the highest index of data which was used. */ -int biguintFromDecimal(Range)(BigDigit[] data, Range s) if ( +int biguintFromDecimal(Range)(BigDigit[] data, Range s) +if ( isInputRange!Range && isSomeChar!(ElementType!Range) && !isInfinite!Range) diff --git a/std/internal/scopebuffer.d b/std/internal/scopebuffer.d index f4d019f49..160b43bc3 100644 --- a/std/internal/scopebuffer.d +++ b/std/internal/scopebuffer.d @@ -93,10 +93,10 @@ textbuf = doSomething(textbuf, args); @system struct ScopeBuffer(T, alias realloc = /*core.stdc.stdlib*/.realloc) - if (isAssignable!T && - !hasElaborateDestructor!T && - !hasElaborateCopyConstructor!T && - !hasElaborateAssign!T) +if (isAssignable!T && + !hasElaborateDestructor!T && + !hasElaborateCopyConstructor!T && + !hasElaborateAssign!T) { import core.stdc.string : memcpy; import core.exception : onOutOfMemoryError; diff --git a/std/internal/test/dummyrange.d b/std/internal/test/dummyrange.d index 4e71f1054..c47e42a86 100644 --- a/std/internal/test/dummyrange.d +++ b/std/internal/test/dummyrange.d @@ -34,7 +34,7 @@ import std.traits : isArray; // can be parametrized with attributes. It just dumbs down an array of // numbers 1..10. struct DummyRange(ReturnBy _r, Length _l, RangeType _rt, T = uint[]) - if (isArray!T) +if (isArray!T) { private static immutable uinttestData = [1U, 2U, 3U, 4U, 5U, 6U, 7U, 8U, 9U, 10U]; @@ -316,7 +316,8 @@ unittest private: -pure struct Cmp(T) if (is(T == uint)) +pure struct Cmp(T) +if (is(T == uint)) { static auto iota(size_t low = 1, size_t high = 11) { @@ -336,7 +337,8 @@ pure struct Cmp(T) if (is(T == uint)) enum dummyValueRslt = 1337U * 2; } -pure struct Cmp(T) if (is(T == double)) +pure struct Cmp(T) +if (is(T == double)) { import std.math : approxEqual; @@ -381,7 +383,8 @@ struct TestFoo } } -pure struct Cmp(T) if (is(T == TestFoo)) +pure struct Cmp(T) +if (is(T == TestFoo)) { import std.math : approxEqual; diff --git a/std/math.d b/std/math.d index 0ce6f21e1..45de1cd7f 100644 --- a/std/math.d +++ b/std/math.d @@ -507,9 +507,9 @@ enum real SQRT1_2 = SQRT2/2; /** $(SQRT)$(HALF) * = hypot(z.re, z.im). */ Num abs(Num)(Num x) @safe pure nothrow - if (is(typeof(Num.init >= 0)) && is(typeof(-Num.init)) && - !(is(Num* : const(ifloat*)) || is(Num* : const(idouble*)) - || is(Num* : const(ireal*)))) +if (is(typeof(Num.init >= 0)) && is(typeof(-Num.init)) && + !(is(Num* : const(ifloat*)) || is(Num* : const(idouble*)) + || is(Num* : const(ireal*)))) { static if (isFloatingPoint!(Num)) return fabs(x); @@ -519,16 +519,16 @@ Num abs(Num)(Num x) @safe pure nothrow /// ditto auto abs(Num)(Num z) @safe pure nothrow @nogc - if (is(Num* : const(cfloat*)) || is(Num* : const(cdouble*)) - || is(Num* : const(creal*))) +if (is(Num* : const(cfloat*)) || is(Num* : const(cdouble*)) + || is(Num* : const(creal*))) { return hypot(z.re, z.im); } /// ditto auto abs(Num)(Num y) @safe pure nothrow @nogc - if (is(Num* : const(ifloat*)) || is(Num* : const(idouble*)) - || is(Num* : const(ireal*))) +if (is(Num* : const(ifloat*)) || is(Num* : const(idouble*)) + || is(Num* : const(ireal*))) { return fabs(y.im); } @@ -572,8 +572,8 @@ auto abs(Num)(Num y) @safe pure nothrow @nogc * is always a real number */ auto conj(Num)(Num z) @safe pure nothrow @nogc - if (is(Num* : const(cfloat*)) || is(Num* : const(cdouble*)) - || is(Num* : const(creal*))) +if (is(Num* : const(cfloat*)) || is(Num* : const(cdouble*)) + || is(Num* : const(creal*))) { //FIXME //Issue 14206 @@ -585,8 +585,8 @@ auto conj(Num)(Num z) @safe pure nothrow @nogc /** ditto */ auto conj(Num)(Num y) @safe pure nothrow @nogc - if (is(Num* : const(ifloat*)) || is(Num* : const(idouble*)) - || is(Num* : const(ireal*))) +if (is(Num* : const(ifloat*)) || is(Num* : const(idouble*)) + || is(Num* : const(ireal*))) { return -y; } @@ -2383,7 +2383,7 @@ creal expi(real y) @trusted pure nothrow @nogc * ) */ T frexp(T)(const T value, out int exp) @trusted pure nothrow @nogc - if (isFloatingPoint!T) +if (isFloatingPoint!T) { Unqual!T vf = value; ushort* vu = cast(ushort*)&vf; @@ -2668,7 +2668,7 @@ T frexp(T)(const T value, out int exp) @trusted pure nothrow @nogc * ) */ int ilogb(T)(const T x) @trusted pure nothrow @nogc - if (isFloatingPoint!T) +if (isFloatingPoint!T) { import core.bitop : bsr; alias F = floatTraits!T; @@ -2809,7 +2809,7 @@ int ilogb(T)(const T x) @trusted pure nothrow @nogc } /// ditto int ilogb(T)(const T x) @safe pure nothrow @nogc - if (isIntegral!T && isUnsigned!T) +if (isIntegral!T && isUnsigned!T) { import core.bitop : bsr; if (x == 0) @@ -2822,7 +2822,7 @@ int ilogb(T)(const T x) @safe pure nothrow @nogc } /// ditto int ilogb(T)(const T x) @safe pure nothrow @nogc - if (isIntegral!T && isSigned!T) +if (isIntegral!T && isSigned!T) { import std.traits : Unsigned; // Note: abs(x) can not be used because the return type is not Unsigned and @@ -3966,7 +3966,7 @@ float floor(float x) @trusted pure nothrow @nogc * rounding mode. */ Unqual!F quantize(alias rfunc = rint, F)(const F val, const F unit) - if (is(typeof(rfunc(F.init)) : F) && isFloatingPoint!F) +if (is(typeof(rfunc(F.init)) : F) && isFloatingPoint!F) { typeof(return) ret = val; if (unit != 0) @@ -4005,7 +4005,7 @@ Unqual!F quantize(alias rfunc = rint, F)(const F val, const F unit) * current rounding mode. */ Unqual!F quantize(real base, alias rfunc = rint, F, E)(const F val, const E exp) - if (is(typeof(rfunc(F.init)) : F) && isFloatingPoint!F && isIntegral!E) +if (is(typeof(rfunc(F.init)) : F) && isFloatingPoint!F && isIntegral!E) { // TODO: Compile-time optimization for power-of-two bases? return quantize!rfunc(val, pow(cast(F)base, exp)); @@ -4013,7 +4013,7 @@ Unqual!F quantize(real base, alias rfunc = rint, F, E)(const F val, const E exp) /// ditto Unqual!F quantize(real base, long exp = 1, alias rfunc = rint, F)(const F val) - if (is(typeof(rfunc(F.init)) : F) && isFloatingPoint!F) +if (is(typeof(rfunc(F.init)) : F) && isFloatingPoint!F) { enum unit = cast(F)pow(base, exp); return quantize!rfunc(val, unit); @@ -4981,7 +4981,7 @@ private: * $(D true) if $(D_PARAM x) is Nan. */ bool isNaN(X)(X x) @nogc @trusted pure nothrow - if (isFloatingPoint!(X)) +if (isFloatingPoint!(X)) { alias F = floatTraits!(X); static if (F.realFormat == RealFormat.ieeeSingle) @@ -5224,7 +5224,7 @@ bool isSubnormal(X)(X x) @trusted pure nothrow @nogc * $(D true) if $(D_PARAM x) is $(PLUSMN)$(INFIN). */ bool isInfinity(X)(X x) @nogc @trusted pure nothrow - if (isFloatingPoint!(X)) +if (isFloatingPoint!(X)) { alias F = floatTraits!(X); static if (F.realFormat == RealFormat.ieeeSingle) @@ -5408,7 +5408,7 @@ int signbit(X)(X x) @nogc @trusted pure nothrow * Return a value composed of to with from's sign bit. */ R copysign(R, X)(R to, X from) @trusted pure nothrow @nogc - if (isFloatingPoint!(R) && isFloatingPoint!(X)) +if (isFloatingPoint!(R) && isFloatingPoint!(X)) { ubyte* pto = cast(ubyte *)&to; const ubyte* pfrom = cast(ubyte *)&from; @@ -5422,7 +5422,7 @@ R copysign(R, X)(R to, X from) @trusted pure nothrow @nogc // ditto R copysign(R, X)(X to, R from) @trusted pure nothrow @nogc - if (isIntegral!(X) && isFloatingPoint!(R)) +if (isIntegral!(X) && isFloatingPoint!(R)) { return copysign(cast(R)to, from); } @@ -6000,7 +6000,7 @@ real fma(real x, real y, real z) @safe pure nothrow @nogc { return (x * y) + z; * Compute the value of x $(SUPERSCRIPT n), where n is an integer */ Unqual!F pow(F, G)(F x, G n) @nogc @trusted pure nothrow - if (isFloatingPoint!(F) && isIntegral!(G)) +if (isFloatingPoint!(F) && isIntegral!(G)) { import std.traits : Unsigned; real p = 1.0, v = void; @@ -6103,7 +6103,7 @@ Unqual!F pow(F, G)(F x, G n) @nogc @trusted pure nothrow * regardless of the value of x. */ typeof(Unqual!(F).init * Unqual!(G).init) pow(F, G)(F x, G n) @nogc @trusted pure nothrow - if (isIntegral!(F) && isIntegral!(G)) +if (isIntegral!(F) && isIntegral!(G)) { if (n<0) return x/0; // Only support positive powers typeof(return) p, v = void; @@ -6160,7 +6160,7 @@ typeof(Unqual!(F).init * Unqual!(G).init) pow(F, G)(F x, G n) @nogc @trusted pur /**Computes integer to floating point powers.*/ real pow(I, F)(I x, F y) @nogc @trusted pure nothrow - if (isIntegral!I && isFloatingPoint!F) +if (isIntegral!I && isFloatingPoint!F) { return pow(cast(real) x, cast(Unqual!F) y); } @@ -6208,7 +6208,7 @@ real pow(I, F)(I x, F y) @nogc @trusted pure nothrow * ) */ Unqual!(Largest!(F, G)) pow(F, G)(F x, G y) @nogc @trusted pure nothrow - if (isFloatingPoint!(F) && isFloatingPoint!(G)) +if (isFloatingPoint!(F) && isFloatingPoint!(G)) { alias Float = typeof(return); @@ -6491,7 +6491,7 @@ Unqual!(Largest!(F, G)) pow(F, G)(F x, G y) @nogc @trusted pure nothrow * ) */ int feqrel(X)(const X x, const X y) @trusted pure nothrow @nogc - if (isFloatingPoint!(X)) +if (isFloatingPoint!(X)) { /* Public Domain. Author: Don Clugston, 18 Aug 2005. */ @@ -6778,7 +6778,7 @@ public: * A = array of coefficients $(SUB a, 0), $(SUB a, 1), etc. */ Unqual!(CommonType!(T1, T2)) poly(T1, T2)(T1 x, in T2[] A) @trusted pure nothrow @nogc - if (isFloatingPoint!T1 && isFloatingPoint!T2) +if (isFloatingPoint!T1 && isFloatingPoint!T2) in { assert(A.length > 0); @@ -6822,7 +6822,7 @@ body } private Unqual!(CommonType!(T1, T2)) polyImplBase(T1, T2)(T1 x, in T2[] A) @trusted pure nothrow @nogc - if (isFloatingPoint!T1 && isFloatingPoint!T2) +if (isFloatingPoint!T1 && isFloatingPoint!T2) { ptrdiff_t i = A.length - 1; typeof(return) r = A[i]; @@ -7207,7 +7207,7 @@ deprecated("Phobos1 math functions are deprecated, use isInfinity ") alias isinf * Standards: Conforms to IEEE 754-2008 */ int cmp(T)(const(T) x, const(T) y) @nogc @trusted pure nothrow - if (isFloatingPoint!T) +if (isFloatingPoint!T) { alias F = floatTraits!T; @@ -7470,13 +7470,15 @@ private T powFloatingPointImpl(PowType type, T)(T x) * Returns: * the next power of two after $(D val) */ -T nextPow2(T)(const T val) if (isIntegral!T) +T nextPow2(T)(const T val) +if (isIntegral!T) { return powIntegralImpl!(PowType.ceil)(val); } /// ditto -T nextPow2(T)(const T val) if (isFloatingPoint!T) +T nextPow2(T)(const T val) +if (isFloatingPoint!T) { return powFloatingPointImpl!(PowType.ceil)(val); } @@ -7593,13 +7595,15 @@ T nextPow2(T)(const T val) if (isFloatingPoint!T) * Returns: * the last power of two before $(D val) */ -T truncPow2(T)(const T val) if (isIntegral!T) +T truncPow2(T)(const T val) +if (isIntegral!T) { return powIntegralImpl!(PowType.floor)(val); } /// ditto -T truncPow2(T)(const T val) if (isFloatingPoint!T) +T truncPow2(T)(const T val) +if (isFloatingPoint!T) { return powFloatingPointImpl!(PowType.floor)(val); } @@ -7708,7 +7712,7 @@ Returns: `true` if `x` is an integer power of two. */ bool isPowerOf2(X)(const X x) pure @safe nothrow @nogc - if (isNumeric!X) +if (isNumeric!X) { static if (isFloatingPoint!X) { diff --git a/std/meta.d b/std/meta.d index 9902b990a..d16624ff4 100644 --- a/std/meta.d +++ b/std/meta.d @@ -246,13 +246,15 @@ package template OldAlias(alias a) import std.traits : isAggregateType, Unqual; -package template OldAlias(T) if (!isAggregateType!T || is(Unqual!T == T)) +package template OldAlias(T) +if (!isAggregateType!T || is(Unqual!T == T)) { alias OldAlias = T; } deprecated("Alias will stop to unqualify user defined types.") -package template OldAlias(T) if (isAggregateType!T && !is(Unqual!T == T)) +package template OldAlias(T) +if (isAggregateType!T && !is(Unqual!T == T)) { alias OldAlias = Unqual!T; } @@ -298,7 +300,7 @@ template staticIndexOf(alias T, TList...) // [internal] private template genericIndexOf(args...) - if (args.length >= 1) +if (args.length >= 1) { alias e = OldAlias!(args[0]); alias tuple = args[1 .. $]; @@ -375,7 +377,7 @@ template Erase(alias T, TList...) // [internal] private template GenericErase(args...) - if (args.length >= 1) +if (args.length >= 1) { alias e = OldAlias!(args[0]); alias tuple = args[1 .. $] ; @@ -434,7 +436,7 @@ template EraseAll(alias T, TList...) // [internal] private template GenericEraseAll(args...) - if (args.length >= 1) +if (args.length >= 1) { alias e = OldAlias!(args[0]); alias tuple = args[1 .. $]; @@ -565,7 +567,7 @@ template Replace(alias T, alias U, TList...) // [internal] private template GenericReplace(args...) - if (args.length >= 2) +if (args.length >= 2) { alias from = OldAlias!(args[0]); alias to = OldAlias!(args[1]); @@ -645,7 +647,7 @@ template ReplaceAll(alias T, alias U, TList...) // [internal] private template GenericReplaceAll(args...) - if (args.length >= 2) +if (args.length >= 2) { alias from = OldAlias!(args[0]); alias to = OldAlias!(args[1]); @@ -1318,7 +1320,8 @@ private template SmartAlias(T...) /** * Creates an `AliasSeq` which repeats a type or an `AliasSeq` exactly `n` times. */ -template Repeat(size_t n, TList...) if (n > 0) +template Repeat(size_t n, TList...) +if (n > 0) { static if (n == 1) { @@ -1445,7 +1448,7 @@ private template staticMerge(alias cmp, int half, Seq...) } private template isLessEq(alias cmp, Seq...) - if (Seq.length == 2) +if (Seq.length == 2) { private enum Result = cmp!(Seq[1], Seq[0]); static if (is(typeof(Result) == bool)) @@ -1513,7 +1516,7 @@ private: * templates, etc.) */ private template isSame(ab...) - if (ab.length == 2) +if (ab.length == 2) { static if (__traits(compiles, expectType!(ab[0]), expectType!(ab[1]))) diff --git a/std/net/curl.d b/std/net/curl.d index 879e708b7..e0b91f1ca 100644 --- a/std/net/curl.d +++ b/std/net/curl.d @@ -398,7 +398,7 @@ private template isCurlConn(Conn) * ---- */ void download(Conn = AutoProtocol)(const(char)[] url, string saveToPath, Conn conn = Conn()) - if (isCurlConn!Conn) +if (isCurlConn!Conn) { static if (is(Conn : HTTP) || is(Conn : FTP)) { @@ -451,7 +451,7 @@ unittest * ---- */ void upload(Conn = AutoProtocol)(string loadFromPath, const(char)[] url, Conn conn = Conn()) - if (isCurlConn!Conn) +if (isCurlConn!Conn) { static if (is(Conn : HTTP)) { @@ -532,7 +532,7 @@ unittest * See_Also: $(LREF HTTP.Method) */ T[] get(Conn = AutoProtocol, T = char)(const(char)[] url, Conn conn = Conn()) - if ( isCurlConn!Conn && (is(T == char) || is(T == ubyte)) ) +if ( isCurlConn!Conn && (is(T == char) || is(T == ubyte)) ) { static if (is(Conn : HTTP)) { @@ -693,7 +693,7 @@ unittest */ T[] put(Conn = AutoProtocol, T = char, PutUnit)(const(char)[] url, const(PutUnit)[] putData, Conn conn = Conn()) - if ( isCurlConn!Conn && (is(T == char) || is(T == ubyte)) ) +if ( isCurlConn!Conn && (is(T == char) || is(T == ubyte)) ) { static if (is(Conn : HTTP)) { @@ -747,7 +747,7 @@ unittest * See_Also: $(LREF HTTP.Method) */ void del(Conn = AutoProtocol)(const(char)[] url, Conn conn = Conn()) - if (isCurlConn!Conn) +if (isCurlConn!Conn) { static if (is(Conn : HTTP)) { @@ -820,7 +820,7 @@ unittest * See_Also: $(LREF HTTP.Method) */ T[] options(T = char)(const(char)[] url, HTTP conn = HTTP()) - if (is(T == char) || is(T == ubyte)) +if (is(T == char) || is(T == ubyte)) { conn.method = HTTP.Method.options; return _basicHTTP!(T)(url, null, conn); @@ -831,7 +831,7 @@ deprecated("options does not send any data") T[] options(T = char, OptionsUnit)(const(char)[] url, const(OptionsUnit)[] optionsData = null, HTTP conn = HTTP()) - if (is(T == char) || is(T == ubyte)) +if (is(T == char) || is(T == ubyte)) { return options!T(url, conn); } @@ -872,7 +872,7 @@ unittest * See_Also: $(LREF HTTP.Method) */ T[] trace(T = char)(const(char)[] url, HTTP conn = HTTP()) - if (is(T == char) || is(T == ubyte)) +if (is(T == char) || is(T == ubyte)) { conn.method = HTTP.Method.trace; return _basicHTTP!(T)(url, cast(void[]) null, conn); @@ -913,7 +913,7 @@ unittest * See_Also: $(LREF HTTP.Method) */ T[] connect(T = char)(const(char)[] url, HTTP conn = HTTP()) - if (is(T == char) || is(T == ubyte)) +if (is(T == char) || is(T == ubyte)) { conn.method = HTTP.Method.connect; return _basicHTTP!(T)(url, cast(void[]) null, conn); @@ -959,7 +959,7 @@ unittest */ T[] patch(T = char, PatchUnit)(const(char)[] url, const(PatchUnit)[] patchData, HTTP conn = HTTP()) - if (is(T == char) || is(T == ubyte)) +if (is(T == char) || is(T == ubyte)) { conn.method = HTTP.Method.patch; return _basicHTTP!(T)(url, patchData, conn); @@ -1370,7 +1370,7 @@ unittest */ auto byChunk(Conn = AutoProtocol) (const(char)[] url, size_t chunkSize = 1024, Conn conn = Conn()) - if (isCurlConn!(Conn)) +if (isCurlConn!(Conn)) { static struct SyncChunkInputRange { @@ -1653,7 +1653,7 @@ auto byLineAsync(Conn = AutoProtocol, Terminator = char, Char = char, PostUnit) KeepTerminator keepTerminator = No.keepTerminator, Terminator terminator = '\n', size_t transmitBuffers = 10, Conn conn = Conn()) - if (isCurlConn!Conn && isSomeChar!Char && isSomeChar!Terminator) +if (isCurlConn!Conn && isSomeChar!Char && isSomeChar!Terminator) { static if (is(Conn : AutoProtocol)) { @@ -1803,7 +1803,7 @@ auto byChunkAsync(Conn = AutoProtocol, PostUnit) (const(char)[] url, const(PostUnit)[] postData, size_t chunkSize = 1024, size_t transmitBuffers = 10, Conn conn = Conn()) - if (isCurlConn!(Conn)) +if (isCurlConn!(Conn)) { static if (is(Conn : AutoProtocol)) { @@ -1832,7 +1832,7 @@ auto byChunkAsync(Conn = AutoProtocol) (const(char)[] url, size_t chunkSize = 1024, size_t transmitBuffers = 10, Conn conn = Conn()) - if (isCurlConn!(Conn)) +if (isCurlConn!(Conn)) { static if (is(Conn : AutoProtocol)) { diff --git a/std/net/isemail.d b/std/net/isemail.d index 3a22a14d9..7239cdd4f 100644 --- a/std/net/isemail.d +++ b/std/net/isemail.d @@ -58,7 +58,8 @@ import std.typecons : Flag, Yes, No; * Returns: an EmailStatus, indicating the status of the email address. */ EmailStatus isEmail (Char) (const(Char)[] email, CheckDns checkDNS = No.checkDns, - EmailStatusCode errorLevel = EmailStatusCode.none) if (isSomeChar!(Char)) +EmailStatusCode errorLevel = EmailStatusCode.none) +if (isSomeChar!(Char)) { import std.algorithm.iteration : uniq; import std.algorithm.searching : canFind, maxElement; @@ -1856,7 +1857,7 @@ unittest * ) */ int compareFirstN (alias pred = "a < b", S1, S2) (S1 s1, S2 s2, size_t length, bool caseInsensitive = false) - if (is(Unqual!(ElementType!(S1)) == dchar) && is(Unqual!(ElementType!(S2)) == dchar)) +if (is(Unqual!(ElementType!(S1)) == dchar) && is(Unqual!(ElementType!(S2)) == dchar)) { import std.uni : icmp; import std.algorithm.comparison : cmp; @@ -1915,7 +1916,8 @@ unittest * * Returns: the popped element */ -ElementType!(A) pop (A) (ref A a) if (isDynamicArray!(A) && !isNarrowString!(A) && isMutable!(A) && !is(A == void[])) +ElementType!(A) pop (A) (ref A a) +if (isDynamicArray!(A) && !isNarrowString!(A) && isMutable!(A) && !is(A == void[])) { auto e = a.back; a.popBack(); diff --git a/std/numeric.d b/std/numeric.d index dd8a002b3..cabe13dc5 100644 --- a/std/numeric.d +++ b/std/numeric.d @@ -109,14 +109,14 @@ private template CustomFloatParams(uint precision, uint exponentWidth, CustomFlo * result can be stored in a custom floating-point value via assignment. */ template CustomFloat(uint bits) - if (bits == 8 || bits == 16 || bits == 32 || bits == 64 || bits == 80) +if (bits == 8 || bits == 16 || bits == 32 || bits == 64 || bits == 80) { alias CustomFloat = CustomFloat!(CustomFloatParams!(bits)); } /// ditto template CustomFloat(uint precision, uint exponentWidth, CustomFloatFlags flags = CustomFloatFlags.ieee) - if (((flags & flags.signed) + precision + exponentWidth) % 8 == 0 && precision + exponentWidth > 0) +if (((flags & flags.signed) + precision + exponentWidth) % 8 == 0 && precision + exponentWidth > 0) { alias CustomFloat = CustomFloat!(CustomFloatParams!(precision, exponentWidth, flags)); } @@ -150,8 +150,8 @@ struct CustomFloat(uint precision, // fraction bits (23 for float) uint exponentWidth, // exponent bits (8 for float) Exponent width CustomFloatFlags flags, uint bias) - if (((flags & flags.signed) + precision + exponentWidth) % 8 == 0 && - precision + exponentWidth > 0) +if (((flags & flags.signed) + precision + exponentWidth) % 8 == 0 && + precision + exponentWidth > 0) { import std.bitmanip : bitfields; import std.meta : staticIndexOf; @@ -678,7 +678,7 @@ always be fastest, as the speed of floating-point calculations depends on very many factors. */ template FPTemporary(F) - if (isFloatingPoint!F) +if (isFloatingPoint!F) { version(X86) alias FPTemporary = real; @@ -797,10 +797,10 @@ public: */ T findRoot(T, DF, DT)(scope DF f, in T a, in T b, scope DT tolerance) //= (T a, T b) => false) - if ( - isFloatingPoint!T && - is(typeof(tolerance(T.init, T.init)) : bool) && - is(typeof(f(T.init)) == R, R) && isFloatingPoint!R +if ( + isFloatingPoint!T && + is(typeof(tolerance(T.init, T.init)) : bool) && + is(typeof(f(T.init)) == R, R) && isFloatingPoint!R ) { immutable fa = f(a); @@ -855,10 +855,10 @@ T findRoot(T, DF)(scope DF f, in T a, in T b) */ Tuple!(T, T, R, R) findRoot(T, R, DF, DT)(scope DF f, in T ax, in T bx, in R fax, in R fbx, scope DT tolerance) // = (T a, T b) => false) - if ( - isFloatingPoint!T && - is(typeof(tolerance(T.init, T.init)) : bool) && - is(typeof(f(T.init)) == R) && isFloatingPoint!R +if ( + isFloatingPoint!T && + is(typeof(tolerance(T.init, T.init)) : bool) && + is(typeof(f(T.init)) == R) && isFloatingPoint!R ) in { @@ -1432,8 +1432,8 @@ findLocalMin(T, DF)( in T relTolerance = sqrt(T.epsilon), in T absTolerance = sqrt(T.epsilon), ) - if (isFloatingPoint!T - && __traits(compiles, {T _ = DF.init(T.init);})) +if (isFloatingPoint!T + && __traits(compiles, {T _ = DF.init(T.init);})) in { assert(isFinite(ax), "ax is not finite"); @@ -1632,7 +1632,7 @@ distance is sought). */ CommonType!(ElementType!(Range1), ElementType!(Range2)) euclideanDistance(Range1, Range2)(Range1 a, Range2 b) - if (isInputRange!(Range1) && isInputRange!(Range2)) +if (isInputRange!(Range1) && isInputRange!(Range2)) { enum bool haveLen = hasLength!(Range1) && hasLength!(Range2); static if (haveLen) assert(a.length == b.length); @@ -1649,7 +1649,7 @@ euclideanDistance(Range1, Range2)(Range1 a, Range2 b) /// Ditto CommonType!(ElementType!(Range1), ElementType!(Range2)) euclideanDistance(Range1, Range2, F)(Range1 a, Range2 b, F limit) - if (isInputRange!(Range1) && isInputRange!(Range2)) +if (isInputRange!(Range1) && isInputRange!(Range2)) { limit *= limit; enum bool haveLen = hasLength!(Range1) && hasLength!(Range2); @@ -1691,8 +1691,8 @@ iteration. */ CommonType!(ElementType!(Range1), ElementType!(Range2)) dotProduct(Range1, Range2)(Range1 a, Range2 b) - if (isInputRange!(Range1) && isInputRange!(Range2) && - !(isArray!(Range1) && isArray!(Range2))) +if (isInputRange!(Range1) && isInputRange!(Range2) && + !(isArray!(Range1) && isArray!(Range2))) { enum bool haveLen = hasLength!(Range1) && hasLength!(Range2); static if (haveLen) assert(a.length == b.length); @@ -1788,7 +1788,7 @@ iteration. If either range has all-zero elements, return 0. */ CommonType!(ElementType!(Range1), ElementType!(Range2)) cosineSimilarity(Range1, Range2)(Range1 a, Range2 b) - if (isInputRange!(Range1) && isInputRange!(Range2)) +if (isInputRange!(Range1) && isInputRange!(Range2)) { enum bool haveLen = hasLength!(Range1) && hasLength!(Range2); static if (haveLen) assert(a.length == b.length); @@ -1829,7 +1829,7 @@ Returns: $(D true) if normalization completed normally, $(D false) if all elements in $(D range) were zero or if $(D range) is empty. */ bool normalize(R)(R range, ElementType!(R) sum = 1) - if (isForwardRange!(R)) +if (isForwardRange!(R)) { ElementType!(R) s = 0; // Step 1: Compute sum and length of the range @@ -1886,7 +1886,7 @@ Compute the sum of binary logarithms of the input range $(D r). The error of this method is much smaller than with a naive sum of log2. */ ElementType!Range sumOfLog2s(Range)(Range r) - if (isInputRange!Range && isFloatingPoint!(ElementType!Range)) +if (isInputRange!Range && isFloatingPoint!(ElementType!Range)) { long exp = 0; Unqual!(typeof(return)) x = 1; @@ -1931,7 +1931,8 @@ be normalized too (i.e., its values should sum to 1). The two-parameter version stops evaluating as soon as the intermediate result is greater than or equal to $(D max). */ -ElementType!Range entropy(Range)(Range r) if (isInputRange!Range) +ElementType!Range entropy(Range)(Range r) +if (isInputRange!Range) { Unqual!(typeof(return)) result = 0.0; for (;!r.empty; r.popFront) @@ -1984,7 +1985,7 @@ positive. */ CommonType!(ElementType!Range1, ElementType!Range2) kullbackLeiblerDivergence(Range1, Range2)(Range1 a, Range2 b) - if (isInputRange!(Range1) && isInputRange!(Range2)) +if (isInputRange!(Range1) && isInputRange!(Range2)) { enum bool haveLen = hasLength!(Range1) && hasLength!(Range2); static if (haveLen) assert(a.length == b.length); @@ -2031,8 +2032,8 @@ or equal to $(D limit). */ CommonType!(ElementType!Range1, ElementType!Range2) jensenShannonDivergence(Range1, Range2)(Range1 a, Range2 b) - if (isInputRange!Range1 && isInputRange!Range2 && - is(CommonType!(ElementType!Range1, ElementType!Range2))) +if (isInputRange!Range1 && isInputRange!Range2 && + is(CommonType!(ElementType!Range1, ElementType!Range2))) { enum bool haveLen = hasLength!(Range1) && hasLength!(Range2); static if (haveLen) assert(a.length == b.length); @@ -2058,9 +2059,9 @@ jensenShannonDivergence(Range1, Range2)(Range1 a, Range2 b) /// Ditto CommonType!(ElementType!Range1, ElementType!Range2) jensenShannonDivergence(Range1, Range2, F)(Range1 a, Range2 b, F limit) - if (isInputRange!Range1 && isInputRange!Range2 && - is(typeof(CommonType!(ElementType!Range1, ElementType!Range2).init - >= F.init) : bool)) +if (isInputRange!Range1 && isInputRange!Range2 && + is(typeof(CommonType!(ElementType!Range1, ElementType!Range2).init + >= F.init) : bool)) { enum bool haveLen = hasLength!(Range1) && hasLength!(Range2); static if (haveLen) assert(a.length == b.length); @@ -2173,8 +2174,8 @@ t.length)) extra bytes of memory and $(BIGOH s.length * t.length) time to complete. */ F gapWeightedSimilarity(alias comp = "a == b", R1, R2, F)(R1 s, R2 t, F lambda) - if (isRandomAccessRange!(R1) && hasLength!(R1) && - isRandomAccessRange!(R2) && hasLength!(R2)) +if (isRandomAccessRange!(R1) && hasLength!(R1) && + isRandomAccessRange!(R2) && hasLength!(R2)) { import std.functional : binaryFun; import std.algorithm.mutation : swap; @@ -2254,8 +2255,8 @@ as $(D sSelfSim) and $(D tSelfSim), respectively. Select!(isFloatingPoint!(F), F, double) gapWeightedSimilarityNormalized(alias comp = "a == b", R1, R2, F) (R1 s, R2 t, F lambda, F sSelfSim = F.init, F tSelfSim = F.init) - if (isRandomAccessRange!(R1) && hasLength!(R1) && - isRandomAccessRange!(R2) && hasLength!(R2)) +if (isRandomAccessRange!(R1) && hasLength!(R1) && + isRandomAccessRange!(R2) && hasLength!(R2)) { static bool uncomputed(F n) { @@ -2303,7 +2304,7 @@ by Rousu et al., with additional algorithmic and systems-level optimizations. */ struct GapWeightedSimilarityIncremental(Range, F = double) - if (isRandomAccessRange!(Range) && hasLength!(Range)) +if (isRandomAccessRange!(Range) && hasLength!(Range)) { import core.stdc.stdlib : malloc, realloc, alloca, free; @@ -3337,7 +3338,7 @@ void slowFourier4(Ret, R)(R range, Ret buf) } N roundDownToPowerOf2(N)(N num) - if (isScalarType!N && !isFloatingPoint!N) +if (isScalarType!N && !isFloatingPoint!N) { import core.bitop : bsr; return num & (cast(N) 1 << bsr(num)); diff --git a/std/path.d b/std/path.d index ea29d538f..c9d86c9c2 100644 --- a/std/path.d +++ b/std/path.d @@ -134,8 +134,8 @@ version(Posix) private alias isSeparator = isDirSeparator; is found. */ private ptrdiff_t lastSeparator(R)(R path) - if (isRandomAccessRange!R && isSomeChar!(ElementType!R) || - isNarrowString!R) +if (isRandomAccessRange!R && isSomeChar!(ElementType!R) || + isNarrowString!R) { auto i = (cast(ptrdiff_t) path.length) - 1; while (i >= 0 && !isSeparator(path[i])) --i; @@ -146,16 +146,16 @@ private ptrdiff_t lastSeparator(R)(R path) version (Windows) { private bool isUNC(R)(R path) - if (isRandomAccessRange!R && isSomeChar!(ElementType!R) || - isNarrowString!R) + if (isRandomAccessRange!R && isSomeChar!(ElementType!R) || + isNarrowString!R) { return path.length >= 3 && isDirSeparator(path[0]) && isDirSeparator(path[1]) && !isDirSeparator(path[2]); } private ptrdiff_t uncRootLength(R)(R path) - if (isRandomAccessRange!R && isSomeChar!(ElementType!R) || - isNarrowString!R) + if (isRandomAccessRange!R && isSomeChar!(ElementType!R) || + isNarrowString!R) in { assert (isUNC(path)); } body { @@ -175,15 +175,15 @@ version (Windows) } private bool hasDrive(R)(R path) - if (isRandomAccessRange!R && isSomeChar!(ElementType!R) || - isNarrowString!R) + if (isRandomAccessRange!R && isSomeChar!(ElementType!R) || + isNarrowString!R) { return path.length >= 2 && isDriveSeparator(path[1]); } private bool isDriveRoot(R)(R path) - if (isRandomAccessRange!R && isSomeChar!(ElementType!R) || - isNarrowString!R) + if (isRandomAccessRange!R && isSomeChar!(ElementType!R) || + isNarrowString!R) { return path.length >= 3 && isDriveSeparator(path[1]) && isDirSeparator(path[2]); @@ -195,8 +195,8 @@ version (Windows) from a path. */ private auto ltrimDirSeparators(R)(R path) - if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementType!R) || - isNarrowString!R) +if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementType!R) || + isNarrowString!R) { static if (isRandomAccessRange!R && hasSlicing!R || isNarrowString!R) { @@ -224,8 +224,8 @@ private auto ltrimDirSeparators(R)(R path) } private auto rtrimDirSeparators(R)(R path) - if (isBidirectionalRange!R && isSomeChar!(ElementType!R) || - isNarrowString!R) +if (isBidirectionalRange!R && isSomeChar!(ElementType!R) || + isNarrowString!R) { static if (isRandomAccessRange!R && hasSlicing!R && hasLength!R || isNarrowString!R) { @@ -254,8 +254,8 @@ private auto rtrimDirSeparators(R)(R path) } private auto trimDirSeparators(R)(R path) - if (isBidirectionalRange!R && isSomeChar!(ElementType!R) || - isNarrowString!R) +if (isBidirectionalRange!R && isSomeChar!(ElementType!R) || + isNarrowString!R) { return ltrimDirSeparators(rtrimDirSeparators(path)); } @@ -348,8 +348,8 @@ else static assert (0); (with suitable adaptations for Windows paths). */ auto baseName(R)(R path) - if (isRandomAccessRange!R && hasSlicing!R && isSomeChar!(ElementType!R) || - is(StringTypeOf!R)) +if (isRandomAccessRange!R && hasSlicing!R && isSomeChar!(ElementType!R) || + is(StringTypeOf!R)) { auto p1 = stripDrive!(BaseOf!R)(path); if (p1.empty) @@ -374,7 +374,7 @@ auto baseName(R)(R path) inout(C)[] baseName(CaseSensitive cs = CaseSensitive.osDefault, C, C1) (inout(C)[] path, in C1[] suffix) @safe pure //TODO: nothrow (because of filenameCmp()) - if (isSomeChar!C && isSomeChar!C1) +if (isSomeChar!C && isSomeChar!C1) { auto p = baseName(path); if (p.length > suffix.length @@ -466,9 +466,9 @@ inout(C)[] baseName(CaseSensitive cs = CaseSensitive.osDefault, C, C1) (with suitable adaptations for Windows paths). */ auto dirName(R)(R path) - if ((isRandomAccessRange!R && hasSlicing!R && hasLength!R && isSomeChar!(ElementType!R) || - isNarrowString!R) && - !isConvertibleToString!R) +if ((isRandomAccessRange!R && hasSlicing!R && hasLength!R && isSomeChar!(ElementType!R) || + isNarrowString!R) && + !isConvertibleToString!R) { static auto result(bool dot, typeof(path[0..1]) p) { @@ -553,7 +553,7 @@ auto dirName(R)(R path) } auto dirName(R)(auto ref R path) - if (isConvertibleToString!R) +if (isConvertibleToString!R) { return dirName!(StringTypeOf!R)(path); } @@ -618,9 +618,9 @@ auto dirName(R)(auto ref R path) A slice of $(D path). */ auto rootName(R)(R path) - if ((isRandomAccessRange!R && hasSlicing!R && hasLength!R && isSomeChar!(ElementType!R) || - isNarrowString!R) && - !isConvertibleToString!R) +if ((isRandomAccessRange!R && hasSlicing!R && hasLength!R && isSomeChar!(ElementType!R) || + isNarrowString!R) && + !isConvertibleToString!R) { if (path.empty) goto Lnull; @@ -694,7 +694,7 @@ Lnull: } auto rootName(R)(R path) - if (isConvertibleToString!R) +if (isConvertibleToString!R) { return rootName!(StringTypeOf!R)(path); } @@ -714,9 +714,9 @@ auto rootName(R)(R path) Always returns an empty range on POSIX. */ auto driveName(R)(R path) - if ((isRandomAccessRange!R && hasSlicing!R && hasLength!R && isSomeChar!(ElementType!R) || - isNarrowString!R) && - !isConvertibleToString!R) +if ((isRandomAccessRange!R && hasSlicing!R && hasLength!R && isSomeChar!(ElementType!R) || + isNarrowString!R) && + !isConvertibleToString!R) { version (Windows) { @@ -751,7 +751,7 @@ auto driveName(R)(R path) } auto driveName(R)(auto ref R path) - if (isConvertibleToString!R) +if (isConvertibleToString!R) { return driveName!(StringTypeOf!R)(path); } @@ -791,9 +791,9 @@ auto driveName(R)(auto ref R path) Returns: A slice of path without the drive component. */ auto stripDrive(R)(R path) - if ((isRandomAccessRange!R && hasSlicing!R && isSomeChar!(ElementType!R) || - isNarrowString!R) && - !isConvertibleToString!R) +if ((isRandomAccessRange!R && hasSlicing!R && isSomeChar!(ElementType!R) || + isNarrowString!R) && + !isConvertibleToString!R) { version(Windows) { @@ -814,7 +814,7 @@ auto stripDrive(R)(R path) } auto stripDrive(R)(auto ref R path) - if (isConvertibleToString!R) +if (isConvertibleToString!R) { return stripDrive!(StringTypeOf!R)(path); } @@ -858,8 +858,8 @@ auto stripDrive(R)(auto ref R path) index of extension separator (the dot), or -1 if not found */ private ptrdiff_t extSeparatorPos(R)(const R path) - if (isRandomAccessRange!R && hasLength!R && isSomeChar!(ElementType!R) || - isNarrowString!R) +if (isRandomAccessRange!R && hasLength!R && isSomeChar!(ElementType!R) || + isNarrowString!R) { for (auto i = path.length; i-- > 0 && !isSeparator(path[i]); ) { @@ -913,8 +913,8 @@ private ptrdiff_t extSeparatorPos(R)(const R path) If there is no _extension, $(D null) is returned. */ auto extension(R)(R path) - if (isRandomAccessRange!R && hasSlicing!R && isSomeChar!(ElementType!R) || - is(StringTypeOf!R)) +if (isRandomAccessRange!R && hasSlicing!R && isSomeChar!(ElementType!R) || + is(StringTypeOf!R)) { auto i = extSeparatorPos!(BaseOf!R)(path); if (i == -1) @@ -965,9 +965,9 @@ auto extension(R)(R path) slice of path with the extension (if any) stripped off */ auto stripExtension(R)(R path) - if ((isRandomAccessRange!R && hasSlicing!R && hasLength!R && isSomeChar!(ElementType!R) || - isNarrowString!R) && - !isConvertibleToString!R) +if ((isRandomAccessRange!R && hasSlicing!R && hasLength!R && isSomeChar!(ElementType!R) || + isNarrowString!R) && + !isConvertibleToString!R) { auto i = extSeparatorPos(path); return (i == -1) ? path : path[0 .. i]; @@ -986,7 +986,7 @@ auto stripExtension(R)(R path) } auto stripExtension(R)(auto ref R path) - if (isConvertibleToString!R) +if (isConvertibleToString!R) { return stripExtension!(StringTypeOf!R)(path); } @@ -1034,7 +1034,7 @@ auto stripExtension(R)(auto ref R path) $(LREF withExtension) which does not allocate and returns a lazy range. */ immutable(Unqual!C1)[] setExtension(C1, C2)(in C1[] path, in C2[] ext) - if (isSomeChar!C1 && !is(C1 == immutable) && is(Unqual!C1 == Unqual!C2)) +if (isSomeChar!C1 && !is(C1 == immutable) && is(Unqual!C1 == Unqual!C2)) { try { @@ -1049,7 +1049,7 @@ immutable(Unqual!C1)[] setExtension(C1, C2)(in C1[] path, in C2[] ext) ///ditto immutable(C1)[] setExtension(C1, C2)(immutable(C1)[] path, const(C2)[] ext) - if (isSomeChar!C1 && is(Unqual!C1 == Unqual!C2)) +if (isSomeChar!C1 && is(Unqual!C1 == Unqual!C2)) { if (ext.length == 0) return stripExtension(path); @@ -1109,10 +1109,10 @@ immutable(C1)[] setExtension(C1, C2)(immutable(C1)[] path, const(C2)[] ext) * $(LREF setExtension) */ auto withExtension(R, C)(R path, C[] ext) - if ((isRandomAccessRange!R && hasSlicing!R && hasLength!R && isSomeChar!(ElementType!R) || - isNarrowString!R) && - !isConvertibleToString!R && - isSomeChar!C) +if ((isRandomAccessRange!R && hasSlicing!R && hasLength!R && isSomeChar!(ElementType!R) || + isNarrowString!R) && + !isConvertibleToString!R && + isSomeChar!C) { import std.range : only, chain; import std.utf : byUTF; @@ -1139,7 +1139,7 @@ auto withExtension(R, C)(R path, C[] ext) } auto withExtension(R, C)(auto ref R path, C[] ext) - if (isConvertibleToString!R) +if (isConvertibleToString!R) { return withExtension!(StringTypeOf!R)(path, ext); } @@ -1162,7 +1162,7 @@ auto withExtension(R, C)(auto ref R path, C[] ext) path is immutable and already has an extension. */ immutable(Unqual!C1)[] defaultExtension(C1, C2)(in C1[] path, in C2[] ext) - if (isSomeChar!C1 && is(Unqual!C1 == Unqual!C2)) +if (isSomeChar!C1 && is(Unqual!C1 == Unqual!C2)) { import std.conv : to; return withDefaultExtension(path, ext).to!(typeof(return)); @@ -1201,10 +1201,10 @@ immutable(Unqual!C1)[] defaultExtension(C1, C2)(in C1[] path, in C2[] ext) * range with the result */ auto withDefaultExtension(R, C)(R path, C[] ext) - if ((isRandomAccessRange!R && hasSlicing!R && hasLength!R && isSomeChar!(ElementType!R) || - isNarrowString!R) && - !isConvertibleToString!R && - isSomeChar!C) +if ((isRandomAccessRange!R && hasSlicing!R && hasLength!R && isSomeChar!(ElementType!R) || + isNarrowString!R) && + !isConvertibleToString!R && + isSomeChar!C) { import std.range : only, chain; import std.utf : byUTF; @@ -1243,7 +1243,7 @@ auto withDefaultExtension(R, C)(R path, C[] ext) } auto withDefaultExtension(R, C)(auto ref R path, C[] ext) - if (isConvertibleToString!R) +if (isConvertibleToString!R) { return withDefaultExtension!(StringTypeOf!R, C)(path, ext); } @@ -1277,7 +1277,7 @@ auto withDefaultExtension(R, C)(auto ref R path, C[] ext) */ immutable(ElementEncodingType!(ElementType!Range))[] buildPath(Range)(Range segments) - if (isInputRange!Range && !isInfinite!Range && isSomeString!(ElementType!Range)) + if (isInputRange!Range && !isInfinite!Range && isSomeString!(ElementType!Range)) { if (segments.empty) return null; @@ -1318,7 +1318,7 @@ immutable(ElementEncodingType!(ElementType!Range))[] /// ditto immutable(C)[] buildPath(C)(const(C)[][] paths...) @safe pure nothrow - if (isSomeChar!C) +if (isSomeChar!C) { return buildPath!(typeof(paths))(paths); } @@ -1451,14 +1451,14 @@ immutable(C)[] buildPath(C)(const(C)[][] paths...) * $(LREF buildPath) */ auto chainPath(R1, R2, Ranges...)(R1 r1, R2 r2, Ranges ranges) - if ((isRandomAccessRange!R1 && hasSlicing!R1 && hasLength!R1 && isSomeChar!(ElementType!R1) || - isNarrowString!R1 && - !isConvertibleToString!R1) && - (isRandomAccessRange!R2 && hasSlicing!R2 && hasLength!R2 && isSomeChar!(ElementType!R2) || - isNarrowString!R2 && - !isConvertibleToString!R2) && - (Ranges.length == 0 || is(typeof(chainPath(r2, ranges)))) - ) +if ((isRandomAccessRange!R1 && hasSlicing!R1 && hasLength!R1 && isSomeChar!(ElementType!R1) || + isNarrowString!R1 && + !isConvertibleToString!R1) && + (isRandomAccessRange!R2 && hasSlicing!R2 && hasLength!R2 && isSomeChar!(ElementType!R2) || + isNarrowString!R2 && + !isConvertibleToString!R2) && + (Ranges.length == 0 || is(typeof(chainPath(r2, ranges)))) + ) { static if (Ranges.length) { @@ -1546,8 +1546,8 @@ auto chainPath(R1, R2, Ranges...)(R1 r1, R2 r2, Ranges ranges) } auto chainPath(Ranges...)(auto ref Ranges ranges) - if (Ranges.length >= 2 && - std.meta.anySatisfy!(isConvertibleToString, Ranges)) +if (Ranges.length >= 2 && + std.meta.anySatisfy!(isConvertibleToString, Ranges)) { import std.meta : staticMap; alias Types = staticMap!(convertToString, Ranges); @@ -1584,7 +1584,7 @@ auto chainPath(Ranges...)(auto ref Ranges ranges) */ immutable(C)[] buildNormalizedPath(C)(const(C[])[] paths...) @trusted pure nothrow - if (isSomeChar!C) +if (isSomeChar!C) { import std.array : array; @@ -1737,9 +1737,9 @@ immutable(C)[] buildNormalizedPath(C)(const(C[])[] paths...) */ auto asNormalizedPath(R)(R path) - if (isSomeChar!(ElementEncodingType!R) && - (isRandomAccessRange!R && hasSlicing!R && hasLength!R || isNarrowString!R) && - !isConvertibleToString!R) +if (isSomeChar!(ElementEncodingType!R) && + (isRandomAccessRange!R && hasSlicing!R && hasLength!R || isNarrowString!R) && + !isConvertibleToString!R) { alias C = Unqual!(ElementEncodingType!R); alias S = typeof(path[0..0]); @@ -1904,7 +1904,7 @@ auto asNormalizedPath(R)(R path) } auto asNormalizedPath(R)(auto ref R path) - if (isConvertibleToString!R) +if (isConvertibleToString!R) { return asNormalizedPath!(StringTypeOf!R)(path); } @@ -2119,9 +2119,9 @@ auto asNormalizedPath(R)(auto ref R path) bidirectional range of slices of `path` */ auto pathSplitter(R)(R path) - if ((isRandomAccessRange!R && hasSlicing!R || - isNarrowString!R) && - !isConvertibleToString!R) +if ((isRandomAccessRange!R && hasSlicing!R || + isNarrowString!R) && + !isConvertibleToString!R) { static struct PathSplitter { @@ -2307,7 +2307,7 @@ auto pathSplitter(R)(R path) } auto pathSplitter(R)(auto ref R path) - if (isConvertibleToString!R) +if (isConvertibleToString!R) { return pathSplitter!(StringTypeOf!R)(path); } @@ -2418,8 +2418,8 @@ auto pathSplitter(R)(auto ref R path) --- */ bool isRooted(R)(R path) - if (isRandomAccessRange!R && isSomeChar!(ElementType!R) || - is(StringTypeOf!R)) +if (isRandomAccessRange!R && isSomeChar!(ElementType!R) || + is(StringTypeOf!R)) { if (path.length >= 1 && isDirSeparator(path[0])) return true; version (Posix) return false; @@ -2492,14 +2492,14 @@ bool isRooted(R)(R path) version (StdDdoc) { bool isAbsolute(R)(R path) pure nothrow @safe - if (isRandomAccessRange!R && isSomeChar!(ElementType!R) || - is(StringTypeOf!R)); + if (isRandomAccessRange!R && isSomeChar!(ElementType!R) || + is(StringTypeOf!R)); } else version (Windows) { bool isAbsolute(R)(R path) - if (isRandomAccessRange!R && isSomeChar!(ElementType!R) || - is(StringTypeOf!R)) + if (isRandomAccessRange!R && isSomeChar!(ElementType!R) || + is(StringTypeOf!R)) { return isDriveRoot!(BaseOf!R)(path) || isUNC!(BaseOf!R)(path); } @@ -2640,9 +2640,9 @@ string absolutePath(string path, lazy string base = getcwd()) $(LREF absolutePath) which returns an allocated string */ auto asAbsolutePath(R)(R path) - if ((isRandomAccessRange!R && isSomeChar!(ElementType!R) || - isNarrowString!R) && - !isConvertibleToString!R) +if ((isRandomAccessRange!R && isSomeChar!(ElementType!R) || + isNarrowString!R) && + !isConvertibleToString!R) { import std.file : getcwd; string base = null; @@ -2668,7 +2668,7 @@ auto asAbsolutePath(R)(R path) } auto asAbsolutePath(R)(auto ref R path) - if (isConvertibleToString!R) +if (isConvertibleToString!R) { return asAbsolutePath!(StringTypeOf!R)(path); } @@ -2812,12 +2812,12 @@ string relativePath(CaseSensitive cs = CaseSensitive.osDefault) */ auto asRelativePath(CaseSensitive cs = CaseSensitive.osDefault, R1, R2) (R1 path, R2 base) - if ((isNarrowString!R1 || - (isRandomAccessRange!R1 && hasSlicing!R1 && isSomeChar!(ElementType!R1)) && - !isConvertibleToString!R1) && - (isNarrowString!R2 || - (isRandomAccessRange!R2 && hasSlicing!R2 && isSomeChar!(ElementType!R2)) && - !isConvertibleToString!R2)) +if ((isNarrowString!R1 || + (isRandomAccessRange!R1 && hasSlicing!R1 && isSomeChar!(ElementType!R1)) && + !isConvertibleToString!R1) && + (isNarrowString!R2 || + (isRandomAccessRange!R2 && hasSlicing!R2 && isSomeChar!(ElementType!R2)) && + !isConvertibleToString!R2)) { bool choosePath = !isAbsolute(path); @@ -2891,7 +2891,7 @@ auto asRelativePath(CaseSensitive cs = CaseSensitive.osDefault, R1, R2) auto asRelativePath(CaseSensitive cs = CaseSensitive.osDefault, R1, R2) (auto ref R1 path, auto ref R2 base) - if (isConvertibleToString!R1 || isConvertibleToString!R2) +if (isConvertibleToString!R1 || isConvertibleToString!R2) { import std.meta : staticMap; alias Types = staticMap!(convertToString, R1, R2); @@ -3026,12 +3026,12 @@ int filenameCharCmp(CaseSensitive cs = CaseSensitive.osDefault)(dchar a, dchar b */ int filenameCmp(CaseSensitive cs = CaseSensitive.osDefault, Range1, Range2) (Range1 filename1, Range2 filename2) - if (isInputRange!Range1 && !isInfinite!Range1 && - isSomeChar!(ElementEncodingType!Range1) && - !isConvertibleToString!Range1 && - isInputRange!Range2 && !isInfinite!Range2 && - isSomeChar!(ElementEncodingType!Range2) && - !isConvertibleToString!Range2) +if (isInputRange!Range1 && !isInfinite!Range1 && + isSomeChar!(ElementEncodingType!Range1) && + !isConvertibleToString!Range1 && + isInputRange!Range2 && !isInfinite!Range2 && + isSomeChar!(ElementEncodingType!Range2) && + !isConvertibleToString!Range2) { alias C1 = Unqual!(ElementEncodingType!Range1); alias C2 = Unqual!(ElementEncodingType!Range2); @@ -3092,7 +3092,7 @@ int filenameCmp(CaseSensitive cs = CaseSensitive.osDefault, Range1, Range2) int filenameCmp(CaseSensitive cs = CaseSensitive.osDefault, Range1, Range2) (auto ref Range1 filename1, auto ref Range2 filename2) - if (isConvertibleToString!Range1 || isConvertibleToString!Range2) +if (isConvertibleToString!Range1 || isConvertibleToString!Range2) { import std.meta : staticMap; alias Types = staticMap!(convertToString, Range1, Range2); @@ -3168,9 +3168,9 @@ int filenameCmp(CaseSensitive cs = CaseSensitive.osDefault, Range1, Range2) bool globMatch(CaseSensitive cs = CaseSensitive.osDefault, C, Range) (Range path, const(C)[] pattern) @safe pure nothrow - if (isForwardRange!Range && !isInfinite!Range && - isSomeChar!(ElementEncodingType!Range) && !isConvertibleToString!Range && - isSomeChar!C && is(Unqual!C == Unqual!(ElementEncodingType!Range))) +if (isForwardRange!Range && !isInfinite!Range && + isSomeChar!(ElementEncodingType!Range) && !isConvertibleToString!Range && + isSomeChar!C && is(Unqual!C == Unqual!(ElementEncodingType!Range))) in { // Verify that pattern[] is valid @@ -3344,7 +3344,7 @@ body bool globMatch(CaseSensitive cs = CaseSensitive.osDefault, C, Range) (auto ref Range path, const(C)[] pattern) @safe pure nothrow - if (isConvertibleToString!Range) +if (isConvertibleToString!Range) { return globMatch!(cs, C, StringTypeOf!Range)(path, pattern); } @@ -3439,9 +3439,9 @@ bool globMatch(CaseSensitive cs = CaseSensitive.osDefault, C, Range) */ bool isValidFilename(Range)(Range filename) - if ((isRandomAccessRange!Range && hasLength!Range && hasSlicing!Range && isSomeChar!(ElementEncodingType!Range) || - isNarrowString!Range) && - !isConvertibleToString!Range) +if ((isRandomAccessRange!Range && hasLength!Range && hasSlicing!Range && isSomeChar!(ElementEncodingType!Range) || + isNarrowString!Range) && + !isConvertibleToString!Range) { import core.stdc.stdio : FILENAME_MAX; if (filename.length == 0 || filename.length >= FILENAME_MAX) return false; @@ -3495,7 +3495,7 @@ unittest } bool isValidFilename(Range)(auto ref Range filename) - if (isConvertibleToString!Range) +if (isConvertibleToString!Range) { return isValidFilename!(StringTypeOf!Range)(filename); } @@ -3582,9 +3582,9 @@ unittest true if $(D path) is a valid _path. */ bool isValidPath(Range)(Range path) - if ((isRandomAccessRange!Range && hasLength!Range && hasSlicing!Range && isSomeChar!(ElementEncodingType!Range) || - isNarrowString!Range) && - !isConvertibleToString!Range) +if ((isRandomAccessRange!Range && hasLength!Range && hasSlicing!Range && isSomeChar!(ElementEncodingType!Range) || + isNarrowString!Range) && + !isConvertibleToString!Range) { alias C = Unqual!(ElementEncodingType!Range); @@ -3718,7 +3718,7 @@ unittest } bool isValidPath(Range)(auto ref Range path) - if (isConvertibleToString!Range) +if (isConvertibleToString!Range) { return isValidPath!(StringTypeOf!Range)(path); } diff --git a/std/process.d b/std/process.d index e45077b1a..4efb24e93 100644 --- a/std/process.d +++ b/std/process.d @@ -2729,7 +2729,7 @@ private char[] charAllocator(size_t size) @safe pure nothrow private char[] escapeWindowsArgumentImpl(alias allocator)(in char[] arg) @safe nothrow - if (is(typeof(allocator(size_t.init)[0] = char.init))) +if (is(typeof(allocator(size_t.init)[0] = char.init))) { // References: // * http://msdn.microsoft.com/en-us/library/windows/desktop/bb776391(v=vs.85).aspx @@ -2862,7 +2862,7 @@ private string escapePosixArgument(in char[] arg) @trusted pure nothrow private char[] escapePosixArgumentImpl(alias allocator)(in char[] arg) @safe nothrow - if (is(typeof(allocator(size_t.init)[0] = char.init))) +if (is(typeof(allocator(size_t.init)[0] = char.init))) { // '\'' means: close quoted part of argument, append an escaped // single quote, and reopen quotes diff --git a/std/random.d b/std/random.d index f3b1b455c..f4fb4c1f3 100644 --- a/std/random.d +++ b/std/random.d @@ -249,7 +249,7 @@ template isSeedable(Rng) Linear Congruential generator. */ struct LinearCongruentialEngine(UIntType, UIntType a, UIntType c, UIntType m) - if (isUnsigned!UIntType) +if (isUnsigned!UIntType) { ///Mark this as a Rng enum bool isUniformRandom = true; @@ -531,7 +531,7 @@ struct MersenneTwisterEngine(UIntType, size_t w, size_t n, size_t m, size_t r, UIntType a, size_t u, UIntType d, size_t s, UIntType b, size_t t, UIntType c, size_t l, UIntType f) - if (isUnsigned!UIntType) +if (isUnsigned!UIntType) { static assert(0 < w && w <= UIntType.sizeof * 8); static assert(1 <= m && m <= n); @@ -993,7 +993,7 @@ alias Mt19937_64 = MersenneTwisterEngine!(ulong, 64, 312, 156, 31, * ) */ struct XorshiftEngine(UIntType, UIntType bits, UIntType a, UIntType b, UIntType c) - if (isUnsigned!UIntType) +if (isUnsigned!UIntType) { static assert(bits == 32 || bits == 64 || bits == 96 || bits == 128 || bits == 160 || bits == 192, "Xorshift supports only 32, 64, 96, 128, 160 and 192 bit versions. " @@ -1364,7 +1364,8 @@ Returns: these parameters */ auto uniform(string boundaries = "[)", T1, T2) -(T1 a, T2 b) if (!is(CommonType!(T1, T2) == void)) +(T1 a, T2 b) +if (!is(CommonType!(T1, T2) == void)) { return uniform!(boundaries, T1, T2, Random)(a, b, rndGen); } @@ -1841,14 +1842,14 @@ if (is(E == enum)) * */ T uniform01(T = double)() - if (isFloatingPoint!T) +if (isFloatingPoint!T) { return uniform01!T(rndGen); } /// ditto T uniform01(T = double, UniformRNG)(ref UniformRNG rng) - if (isFloatingPoint!T && isUniformRNG!UniformRNG) +if (isFloatingPoint!T && isUniformRNG!UniformRNG) out (result) { assert(0 <= result); @@ -1943,7 +1944,7 @@ array of size $(D n) of positive numbers of type $(D F) that sum to $(D 1). If $(D useThis) is provided, it is used as storage. */ F[] uniformDistribution(F = double)(size_t n, F[] useThis = null) - if (isFloatingPoint!F) +if (isFloatingPoint!F) { import std.numeric : normalize; useThis.length = n; @@ -1985,7 +1986,7 @@ Returns: */ auto ref choice(Range, RandomGen = Random)(auto ref Range range, ref RandomGen urng = rndGen) - if (isRandomAccessRange!Range && hasLength!Range && isUniformRNG!RandomGen) +if (isRandomAccessRange!Range && hasLength!Range && isUniformRNG!RandomGen) { assert(range.length > 0, __PRETTY_FUNCTION__ ~ ": invalid Range supplied. Range cannot be empty"); @@ -2063,14 +2064,14 @@ Params: */ void randomShuffle(Range, RandomGen)(Range r, ref RandomGen gen) - if (isRandomAccessRange!Range && isUniformRNG!RandomGen) +if (isRandomAccessRange!Range && isUniformRNG!RandomGen) { return partialShuffle!(Range, RandomGen)(r, r.length, gen); } /// ditto void randomShuffle(Range)(Range r) - if (isRandomAccessRange!Range) +if (isRandomAccessRange!Range) { return randomShuffle(r, rndGen); } @@ -2112,7 +2113,7 @@ Params: specified, defaults to $(D rndGen) */ void partialShuffle(Range, RandomGen)(Range r, in size_t n, ref RandomGen gen) - if (isRandomAccessRange!Range && isUniformRNG!RandomGen) +if (isRandomAccessRange!Range && isUniformRNG!RandomGen) { import std.exception : enforce; import std.algorithm.mutation : swapAt; @@ -2125,7 +2126,7 @@ void partialShuffle(Range, RandomGen)(Range r, in size_t n, ref RandomGen gen) /// ditto void partialShuffle(Range)(Range r, in size_t n) - if (isRandomAccessRange!Range) +if (isRandomAccessRange!Range) { return partialShuffle(r, n, rndGen); } @@ -2225,7 +2226,7 @@ if (isNumeric!Num) } private size_t diceImpl(Rng, Range)(ref Rng rng, scope Range proportions) - if (isForwardRange!Range && isNumeric!(ElementType!Range) && isForwardRange!Rng) +if (isForwardRange!Range && isNumeric!(ElementType!Range) && isForwardRange!Rng) in { import std.algorithm.searching : all; @@ -2316,7 +2317,7 @@ foreach (e; randomCover(a, rndGen)) // ... so this second random cover ---- */ struct RandomCover(Range, UniformRNG = void) - if (isRandomAccessRange!Range && (isUniformRNG!UniformRNG || is(UniformRNG == void))) +if (isRandomAccessRange!Range && (isUniformRNG!UniformRNG || is(UniformRNG == void))) { private Range _input; private bool[] _chosen; @@ -2433,14 +2434,14 @@ struct RandomCover(Range, UniformRNG = void) /// Ditto auto randomCover(Range, UniformRNG)(Range r, auto ref UniformRNG rng) - if (isRandomAccessRange!Range && isUniformRNG!UniformRNG) +if (isRandomAccessRange!Range && isUniformRNG!UniformRNG) { return RandomCover!(Range, UniformRNG)(r, rng); } /// Ditto auto randomCover(Range)(Range r) - if (isRandomAccessRange!Range) +if (isRandomAccessRange!Range) { return RandomCover!(Range, void)(r); } @@ -2585,7 +2586,7 @@ foreach (e; randomSample(a, 5, rndGen)) // ... so this second random ---- */ struct RandomSample(Range, UniformRNG = void) - if (isInputRange!Range && (isUniformRNG!UniformRNG || is(UniformRNG == void))) +if (isInputRange!Range && (isUniformRNG!UniformRNG || is(UniformRNG == void))) { private size_t _available, _toSelect; private enum ushort _alphaInverse = 13; // Vitter's recommended value. @@ -2973,28 +2974,28 @@ Variable names are chosen to match those in Vitter's paper. /// Ditto auto randomSample(Range)(Range r, size_t n, size_t total) - if (isInputRange!Range) +if (isInputRange!Range) { return RandomSample!(Range, void)(r, n, total); } /// Ditto auto randomSample(Range)(Range r, size_t n) - if (isInputRange!Range && hasLength!Range) +if (isInputRange!Range && hasLength!Range) { return RandomSample!(Range, void)(r, n, r.length); } /// Ditto auto randomSample(Range, UniformRNG)(Range r, size_t n, size_t total, auto ref UniformRNG rng) - if (isInputRange!Range && isUniformRNG!UniformRNG) +if (isInputRange!Range && isUniformRNG!UniformRNG) { return RandomSample!(Range, UniformRNG)(r, n, total, rng); } /// Ditto auto randomSample(Range, UniformRNG)(Range r, size_t n, auto ref UniformRNG rng) - if (isInputRange!Range && hasLength!Range && isUniformRNG!UniformRNG) +if (isInputRange!Range && hasLength!Range && isUniformRNG!UniformRNG) { return RandomSample!(Range, UniformRNG)(r, n, r.length, rng); } diff --git a/std/range/package.d b/std/range/package.d index 0c2a7c418..39f6d9455 100644 --- a/std/range/package.d +++ b/std/range/package.d @@ -1745,7 +1745,7 @@ unittest import std.algorithm.comparison : equal; auto interleave(R, E)(R range, E element) - if ((isInputRange!R && hasLength!R) || isForwardRange!R) + if ((isInputRange!R && hasLength!R) || isForwardRange!R) { static if (hasLength!R) immutable len = range.length; @@ -2461,7 +2461,8 @@ regardless of $(D R)'s capabilities, as long as it is a forward range. (D R) is an input range but not a forward range, return type is an input range with all random-access capabilites except save. */ -auto takeOne(R)(R source) if (isInputRange!R) +auto takeOne(R)(R source) +if (isInputRange!R) { static if (hasSlicing!R) { @@ -2577,7 +2578,7 @@ pure @safe unittest capabilities. +/ auto takeNone(R)() - if (isInputRange!R) +if (isInputRange!R) { return typeof(takeOne(R.init)).init; } @@ -2604,7 +2605,7 @@ pure @safe nothrow @nogc unittest $(D takeExactly(range, 0)). +/ auto takeNone(R)(R range) - if (isInputRange!R) +if (isInputRange!R) { import std.traits : isDynamicArray; //Makes it so that calls to takeNone which don't use UFCS still work with a @@ -2780,8 +2781,8 @@ pure @safe nothrow unittest + Returns the _tail of $(D _range) augmented with length information +/ auto tail(Range)(Range range, size_t n) - if (isInputRange!Range && !isInfinite!Range && - (hasLength!Range || isForwardRange!Range)) +if (isInputRange!Range && !isInfinite!Range && + (hasLength!Range || isForwardRange!Range)) { static if (hasLength!Range) { @@ -2899,14 +2900,14 @@ pure @safe nothrow @nogc unittest $(REF popFront, std, range, primitives),$(REF popBackN, std, range, primitives) +/ R drop(R)(R range, size_t n) - if (isInputRange!R) +if (isInputRange!R) { range.popFrontN(n); return range; } /// ditto R dropBack(R)(R range, size_t n) - if (isBidirectionalRange!R) +if (isBidirectionalRange!R) { range.popBackN(n); return range; @@ -2989,14 +2990,14 @@ R dropBack(R)(R range, size_t n) $(REF popBackExcatly, std, range, primitives) +/ R dropExactly(R)(R range, size_t n) - if (isInputRange!R) +if (isInputRange!R) { popFrontExactly(range, n); return range; } /// ditto R dropBackExactly(R)(R range, size_t n) - if (isBidirectionalRange!R) +if (isBidirectionalRange!R) { popBackExactly(range, n); return range; @@ -3032,14 +3033,14 @@ R dropBackExactly(R)(R range, size_t n) $(D range.popBack()). +/ R dropOne(R)(R range) - if (isInputRange!R) +if (isInputRange!R) { range.popFront(); return range; } /// ditto R dropBackOne(R)(R range) - if (isBidirectionalRange!R) +if (isBidirectionalRange!R) { range.popBack(); return range; @@ -3216,7 +3217,7 @@ The resulting range will call `fun()` on construction, and every call to Returns: an `inputRange` where each element represents another call to fun. */ auto generate(Fun)(Fun fun) - if (isCallable!fun) +if (isCallable!fun) { auto gen = Generator!(Fun)(fun); gen.popFront(); // prime the first element @@ -3225,7 +3226,7 @@ auto generate(Fun)(Fun fun) /// ditto auto generate(alias fun)() - if (isCallable!fun) +if (isCallable!fun) { auto gen = Generator!(fun)(); gen.popFront(); // prime the first element @@ -3386,7 +3387,7 @@ Note: The input range must not be empty. Tip: This is a great way to implement simple circular buffers. */ struct Cycle(R) - if (isForwardRange!R && !isInfinite!R) +if (isForwardRange!R && !isInfinite!R) { static if (isRandomAccessRange!R && hasLength!R) { @@ -3553,14 +3554,14 @@ struct Cycle(R) /// ditto template Cycle(R) - if (isInfinite!R) +if (isInfinite!R) { alias Cycle = R; } /// struct Cycle(R) - if (isStaticArray!R) +if (isStaticArray!R) { private alias ElementType = typeof(R.init[0]); private ElementType* _ptr; @@ -3643,7 +3644,7 @@ nothrow: /// Ditto Cycle!R cycle(R)(R input) - if (isForwardRange!R && !isInfinite!R) +if (isForwardRange!R && !isInfinite!R) { assert(!input.empty, "Attempting to pass an empty input to cycle"); return Cycle!R(input); @@ -3664,7 +3665,7 @@ Cycle!R cycle(R)(R input) /// Ditto Cycle!R cycle(R)(R input, size_t index = 0) - if (isRandomAccessRange!R && !isInfinite!R) +if (isRandomAccessRange!R && !isInfinite!R) { assert(!input.empty, "Attempting to pass an empty input to cycle"); return Cycle!R(input, index); @@ -3672,14 +3673,14 @@ Cycle!R cycle(R)(R input, size_t index = 0) /// Ditto Cycle!R cycle(R)(R input) - if (isInfinite!R) +if (isInfinite!R) { return input; } /// Ditto Cycle!R cycle(R)(ref R input, size_t index = 0) @system - if (isStaticArray!R) +if (isStaticArray!R) { return Cycle!R(input, index); } @@ -3878,7 +3879,7 @@ private alias lengthType(R) = typeof(R.init.length.init); `sp` is set to `StoppingPolicy.requireSameLength`. */ struct Zip(Ranges...) - if (Ranges.length && allSatisfy!(isInputRange, Ranges)) +if (Ranges.length && allSatisfy!(isInputRange, Ranges)) { import std.format : format; //for generic mixins import std.typecons : Tuple; @@ -4223,7 +4224,7 @@ struct Zip(Ranges...) /// Ditto auto zip(Ranges...)(Ranges ranges) - if (Ranges.length && allSatisfy!(isInputRange, Ranges)) +if (Ranges.length && allSatisfy!(isInputRange, Ranges)) { return Zip!Ranges(ranges); } @@ -4281,7 +4282,7 @@ pure unittest /// Ditto auto zip(Ranges...)(StoppingPolicy sp, Ranges ranges) - if (Ranges.length && allSatisfy!(isInputRange, Ranges)) +if (Ranges.length && allSatisfy!(isInputRange, Ranges)) { return Zip!Ranges(ranges, sp); } @@ -4601,7 +4602,7 @@ private string lockstepMixin(Ranges...)(bool withIndex, bool reverse) Use `zip` if you want to pass the result to a range function. */ struct Lockstep(Ranges...) - if (Ranges.length > 1 && allSatisfy!(isInputRange, Ranges)) +if (Ranges.length > 1 && allSatisfy!(isInputRange, Ranges)) { /// this(R ranges, StoppingPolicy sp = StoppingPolicy.shortest) @@ -4684,13 +4685,13 @@ template Lockstep(Range) /// Ditto Lockstep!(Ranges) lockstep(Ranges...)(Ranges ranges) - if (allSatisfy!(isInputRange, Ranges)) +if (allSatisfy!(isInputRange, Ranges)) { return Lockstep!(Ranges)(ranges); } /// Ditto Lockstep!(Ranges) lockstep(Ranges...)(Ranges ranges, StoppingPolicy s) - if (allSatisfy!(isInputRange, Ranges)) +if (allSatisfy!(isInputRange, Ranges)) { static if (Ranges.length > 1) return Lockstep!Ranges(ranges, s); @@ -5306,7 +5307,7 @@ if ((isIntegral!(CommonType!(B, E)) || isPointer!(CommonType!(B, E))) /// Ditto auto iota(B, E)(B begin, E end) - if (isFloatingPoint!(CommonType!(B, E))) +if (isFloatingPoint!(CommonType!(B, E))) { return iota(begin, end, CommonType!(B, E)(1)); } @@ -5708,11 +5709,11 @@ unittest */ /// ditto auto iota(B, E)(B begin, E end) - if (!isIntegral!(CommonType!(B, E)) && - !isFloatingPoint!(CommonType!(B, E)) && - !isPointer!(CommonType!(B, E)) && - is(typeof((ref B b) { ++b; })) && - (is(typeof(B.init < E.init)) || is(typeof(B.init == E.init))) ) +if (!isIntegral!(CommonType!(B, E)) && + !isFloatingPoint!(CommonType!(B, E)) && + !isPointer!(CommonType!(B, E)) && + is(typeof((ref B b) { ++b; })) && + (is(typeof(B.init < E.init)) || is(typeof(B.init == E.init))) ) { static struct Result { @@ -6422,9 +6423,9 @@ Transversal!(RangeOfRanges, opt) transversal } struct Transposed(RangeOfRanges) - if (isForwardRange!RangeOfRanges && - isInputRange!(ElementType!RangeOfRanges) && - hasAssignableElements!RangeOfRanges) +if (isForwardRange!RangeOfRanges && + isInputRange!(ElementType!RangeOfRanges) && + hasAssignableElements!RangeOfRanges) { //alias ElementType = typeof(map!"a.front"(RangeOfRanges.init)); @@ -6508,9 +6509,9 @@ Given a range of ranges, returns a range of ranges where the $(I i)'th subrange contains the $(I i)'th elements of the original subranges. */ Transposed!RangeOfRanges transposed(RangeOfRanges)(RangeOfRanges rr) - if (isForwardRange!RangeOfRanges && - isInputRange!(ElementType!RangeOfRanges) && - hasAssignableElements!RangeOfRanges) +if (isForwardRange!RangeOfRanges && + isInputRange!(ElementType!RangeOfRanges) && + hasAssignableElements!RangeOfRanges) { return Transposed!RangeOfRanges(rr); } @@ -6572,8 +6573,8 @@ bidirectional or random-access if $(D Indices) is bidirectional or random-access, respectively. */ struct Indexed(Source, Indices) - if (isRandomAccessRange!Source && isInputRange!Indices && - is(typeof(Source.init[ElementType!(Indices).init]))) +if (isRandomAccessRange!Source && isInputRange!Indices && + is(typeof(Source.init[ElementType!(Indices).init]))) { this(Source source, Indices indices) { @@ -6830,7 +6831,7 @@ divisible by $(D chunkSize), the back element of this range will contain fewer than $(D chunkSize) elements. */ struct Chunks(Source) - if (isForwardRange!Source) +if (isForwardRange!Source) { /// Standard constructor this(Source source, size_t chunkSize) @@ -7138,7 +7139,7 @@ elements. If $(D source.length < chunkCount), some chunks will be empty. $(D chunkCount) must not be zero, unless $(D source) is also empty. */ struct EvenChunks(Source) - if (isForwardRange!Source && hasLength!Source) +if (isForwardRange!Source && hasLength!Source) { /// Standard constructor this(Source source, size_t chunkCount) @@ -7525,7 +7526,7 @@ Returns: See_Also: $(LREF chain) to chain ranges */ auto only(Values...)(auto ref Values values) - if (!is(CommonType!Values == void) || Values.length == 0) +if (!is(CommonType!Values == void) || Values.length == 0) { return OnlyResult!(CommonType!Values, Values.length)(values); } @@ -7763,7 +7764,7 @@ Useful for using $(D foreach) with an index loop variable: ---- */ auto enumerate(Enumerator = size_t, Range)(Range range, Enumerator start = 0) - if (isIntegral!Enumerator && isInputRange!Range) +if (isIntegral!Enumerator && isInputRange!Range) in { static if (hasLength!Range) @@ -8913,7 +8914,7 @@ unittest range is returned rather than a `RefRange`. +/ struct RefRange(R) - if (isInputRange!R) +if (isInputRange!R) { public: @@ -9631,14 +9632,14 @@ unittest // issue 14575 /// ditto auto refRange(R)(R* range) - if (isInputRange!R && !is(R == class)) +if (isInputRange!R && !is(R == class)) { return RefRange!R(range); } /// ditto auto refRange(R)(R* range) - if (isInputRange!R && is(R == class)) +if (isInputRange!R && is(R == class)) { return *range; } @@ -9688,7 +9689,7 @@ auto refRange(R)(R* range) } private struct Bitwise(R) - if (isInputRange!R && isIntegral!(ElementType!R)) +if (isInputRange!R && isIntegral!(ElementType!R)) { private: alias ElemType = ElementType!R; @@ -9946,7 +9947,7 @@ Returns: and random access capabilities */ auto bitwise(R)(auto ref R range) - if (isInputRange!R && isIntegral!(ElementType!R)) +if (isInputRange!R && isIntegral!(ElementType!R)) { return Bitwise!R(range); } @@ -10569,7 +10570,8 @@ Returns: See Also: $(REF rightJustifier, std, string) */ -auto padRight(R, E)(R r, E e, size_t n) if ( +auto padRight(R, E)(R r, E e, size_t n) +if ( isInputRange!R && !isInfinite!R && !is(CommonType!(ElementType!R, E) == void)) diff --git a/std/range/primitives.d b/std/range/primitives.d index 915119565..e1f07737a 100644 --- a/std/range/primitives.d +++ b/std/range/primitives.d @@ -1607,7 +1607,7 @@ Infinite ranges are compatible, provided the parameter $(D upTo) is specified, in which case the implementation simply returns upTo. */ auto walkLength(Range)(Range range) - if (isInputRange!Range && !isInfinite!Range) +if (isInputRange!Range && !isInfinite!Range) { static if (hasLength!Range) return range.length; @@ -1621,7 +1621,7 @@ auto walkLength(Range)(Range range) } /// ditto auto walkLength(Range)(Range range, const size_t upTo) - if (isInputRange!Range) +if (isInputRange!Range) { static if (hasLength!Range) return range.length; @@ -1680,7 +1680,7 @@ auto walkLength(Range)(Range range, const size_t upTo) See_Also: $(REF drop, std, range), $(REF dropBack, std, range) */ size_t popFrontN(Range)(ref Range r, size_t n) - if (isInputRange!Range) +if (isInputRange!Range) { static if (hasLength!Range) { @@ -1716,7 +1716,7 @@ size_t popFrontN(Range)(ref Range r, size_t n) /// ditto size_t popBackN(Range)(ref Range r, size_t n) - if (isBidirectionalRange!Range) +if (isBidirectionalRange!Range) { static if (hasLength!Range) { @@ -1813,7 +1813,7 @@ size_t popBackN(Range)(ref Range r, size_t n) See_Also: $(REF dropExcatly, std, range), $(REF dropBackExactly, std, range) */ void popFrontExactly(Range)(ref Range r, size_t n) - if (isInputRange!Range) +if (isInputRange!Range) { static if (hasLength!Range) assert(n <= r.length, "range is smaller than amount of items to pop"); @@ -1829,7 +1829,7 @@ void popFrontExactly(Range)(ref Range r, size_t n) /// ditto void popBackExactly(Range)(ref Range r, size_t n) - if (isBidirectionalRange!Range) +if (isBidirectionalRange!Range) { static if (hasLength!Range) assert(n <= r.length, "range is smaller than amount of items to pop"); @@ -2294,7 +2294,8 @@ if (!isNarrowString!(T[]) && !is(T[] == void[])) } /// ditto -@property dchar front(T)(T[] a) @safe pure if (isNarrowString!(T[])) +@property dchar front(T)(T[] a) @safe pure +if (isNarrowString!(T[])) { import std.utf : decode; assert(a.length, "Attempting to fetch the front of an empty array of " ~ T.stringof); @@ -2337,7 +2338,8 @@ if (!isNarrowString!(T[]) && !is(T[] == void[])) /// ditto // Specialization for strings -@property dchar back(T)(T[] a) @safe pure if (isNarrowString!(T[])) +@property dchar back(T)(T[] a) @safe pure +if (isNarrowString!(T[])) { import std.utf : decode, strideBack; assert(a.length, "Attempting to fetch the back of an empty array of " ~ T.stringof); diff --git a/std/regex/internal/ir.d b/std/regex/internal/ir.d index b5d3417b9..290dda5ab 100644 --- a/std/regex/internal/ir.d +++ b/std/regex/internal/ir.d @@ -592,7 +592,7 @@ package(std.regex): //Simple UTF-string abstraction compatible with stream interface struct Input(Char) - if (is(Char :dchar)) +if (is(Char :dchar)) { import std.utf : decode; alias DataIndex = size_t; diff --git a/std/regex/internal/parser.d b/std/regex/internal/parser.d index 49f6b4557..23cbf3280 100644 --- a/std/regex/internal/parser.d +++ b/std/regex/internal/parser.d @@ -38,7 +38,7 @@ auto makeRegex(S, CG)(Parser!(S, CG) p) // helper for unittest auto makeRegex(S)(S arg) - if (isSomeString!S) +if (isSomeString!S) { return makeRegex(Parser!(S, CodeGen)(arg, "")); } @@ -614,7 +614,7 @@ enum maxCumulativeRepetitionLength = 2^^20; enum infinite = ~0u; struct Parser(R, Generator) - if (isForwardRange!R && is(ElementType!R : dchar)) +if (isForwardRange!R && is(ElementType!R : dchar)) { dchar _current; bool empty; diff --git a/std/regex/internal/thompson.d b/std/regex/internal/thompson.d index 3065ee6fc..b1c4d55ec 100644 --- a/std/regex/internal/thompson.d +++ b/std/regex/internal/thompson.d @@ -715,7 +715,7 @@ template ThompsonOps(E,S, bool withInput:false) never looking at the same char twice +/ @trusted struct ThompsonMatcher(Char, StreamType = Input!Char) - if (is(Char : dchar)) +if (is(Char : dchar)) { alias DataIndex = Stream.DataIndex; alias Stream = StreamType; diff --git a/std/regex/package.d b/std/regex/package.d index 515cab9dc..1fb2a070a 100644 --- a/std/regex/package.d +++ b/std/regex/package.d @@ -321,7 +321,7 @@ public alias StaticRegex(Char) = std.regex.internal.ir.StaticRegex!(Char); Throws: $(D RegexException) if there were any errors during compilation. +/ @trusted public auto regex(S)(S[] patterns, const(char)[] flags="") - if (isSomeString!(S)) +if (isSomeString!(S)) { import std.array : appender; import std.functional : memoize; @@ -352,7 +352,7 @@ public alias StaticRegex(Char) = std.regex.internal.ir.StaticRegex!(Char); ///ditto @trusted public auto regex(S)(S pattern, const(char)[] flags="") - if (isSomeString!(S)) +if (isSomeString!(S)) { return regex([pattern], flags); } @@ -372,7 +372,7 @@ unittest } public auto regexImpl(S)(S pattern, const(char)[] flags="") - if (isSomeString!(S)) +if (isSomeString!(S)) { import std.regex.internal.parser : Parser, CodeGen; auto parser = Parser!(Unqual!(typeof(pattern)), CodeGen)(pattern, flags); @@ -419,7 +419,7 @@ enum isRegexFor(RegEx, R) = is(RegEx == Regex!(BasicElementOf!R)) First element of range is the whole match. +/ @trusted public struct Captures(R, DIndex = size_t) - if (isSomeString!R) +if (isSomeString!R) {//@trusted because of union inside alias DataIndex = DIndex; alias String = R; @@ -654,7 +654,7 @@ unittest and is automatically deduced in a call to $(D match)/$(D bmatch). +/ @trusted public struct RegexMatch(R, alias Engine = ThompsonMatcher) - if (isSomeString!R) +if (isSomeString!R) { private: import core.stdc.stdlib : malloc, free; @@ -812,7 +812,7 @@ private enum isReplaceFunctor(alias fun, R) = // the lowest level - just stuff replacements into the sink private @trusted void replaceCapturesInto(alias output, Sink, R, T) (ref Sink sink, R input, T captures) - if (isOutputRange!(Sink, dchar) && isSomeString!R) +if (isOutputRange!(Sink, dchar) && isSomeString!R) { if (captures.empty) { @@ -832,7 +832,7 @@ private @trusted void replaceCapturesInto(alias output, Sink, R, T) // ditto for a range of captures private void replaceMatchesInto(alias output, Sink, R, T) (ref Sink sink, R input, T matches) - if (isOutputRange!(Sink, dchar) && isSomeString!R) +if (isOutputRange!(Sink, dchar) && isSomeString!R) { size_t offset = 0; foreach (cap; matches) @@ -850,7 +850,7 @@ private void replaceMatchesInto(alias output, Sink, R, T) // a general skeleton of replaceFirst private R replaceFirstWith(alias output, R, RegEx)(R input, RegEx re) - if (isSomeString!R && isRegexFor!(RegEx, R)) +if (isSomeString!R && isRegexFor!(RegEx, R)) { import std.array : appender; auto data = matchFirst(input, re); @@ -865,7 +865,7 @@ private R replaceFirstWith(alias output, R, RegEx)(R input, RegEx re) // the method parameter allows old API to ride on the back of the new one private R replaceAllWith(alias output, alias method=matchAll, R, RegEx)(R input, RegEx re) - if (isSomeString!R && isRegexFor!(RegEx, R)) +if (isSomeString!R && isRegexFor!(RegEx, R)) { import std.array : appender; auto matches = method(input, re); //inout(C)[] fails @@ -894,7 +894,7 @@ private R replaceAllWith(alias output, +/ public auto match(R, RegEx)(R input, RegEx re) - if (isSomeString!R && is(RegEx == Regex!(BasicElementOf!R))) +if (isSomeString!R && is(RegEx == Regex!(BasicElementOf!R))) { import std.regex.internal.thompson : ThompsonMatcher; return RegexMatch!(Unqual!(typeof(input)),ThompsonMatcher)(input, re); @@ -902,14 +902,14 @@ public auto match(R, RegEx)(R input, RegEx re) ///ditto public auto match(R, String)(R input, String re) - if (isSomeString!R && isSomeString!String) +if (isSomeString!R && isSomeString!String) { import std.regex.internal.thompson : ThompsonMatcher; return RegexMatch!(Unqual!(typeof(input)),ThompsonMatcher)(input, regex(re)); } public auto match(R, RegEx)(R input, RegEx re) - if (isSomeString!R && is(RegEx == StaticRegex!(BasicElementOf!R))) +if (isSomeString!R && is(RegEx == StaticRegex!(BasicElementOf!R))) { import std.regex.internal.backtracking : BacktrackingMatcher; return RegexMatch!(Unqual!(typeof(input)),BacktrackingMatcher!true)(input, re); @@ -934,7 +934,7 @@ public auto match(R, RegEx)(R input, RegEx re) if there was a match, otherwise an empty $(LREF Captures) object. +/ public auto matchFirst(R, RegEx)(R input, RegEx re) - if (isSomeString!R && is(RegEx == Regex!(BasicElementOf!R))) +if (isSomeString!R && is(RegEx == Regex!(BasicElementOf!R))) { import std.regex.internal.thompson : ThompsonMatcher; return matchOnce!ThompsonMatcher(input, re); @@ -942,7 +942,7 @@ public auto matchFirst(R, RegEx)(R input, RegEx re) ///ditto public auto matchFirst(R, String)(R input, String re) - if (isSomeString!R && isSomeString!String) +if (isSomeString!R && isSomeString!String) { import std.regex.internal.thompson : ThompsonMatcher; return matchOnce!ThompsonMatcher(input, regex(re)); @@ -950,14 +950,14 @@ public auto matchFirst(R, String)(R input, String re) ///ditto public auto matchFirst(R, String)(R input, String[] re...) - if (isSomeString!R && isSomeString!String) +if (isSomeString!R && isSomeString!String) { import std.regex.internal.thompson : ThompsonMatcher; return matchOnce!ThompsonMatcher(input, regex(re)); } public auto matchFirst(R, RegEx)(R input, RegEx re) - if (isSomeString!R && is(RegEx == StaticRegex!(BasicElementOf!R))) +if (isSomeString!R && is(RegEx == StaticRegex!(BasicElementOf!R))) { import std.regex.internal.backtracking : BacktrackingMatcher; return matchOnce!(BacktrackingMatcher!true)(input, re); @@ -985,7 +985,7 @@ public auto matchFirst(R, RegEx)(R input, RegEx re) after the first match was found or an empty one if not present. +/ public auto matchAll(R, RegEx)(R input, RegEx re) - if (isSomeString!R && is(RegEx == Regex!(BasicElementOf!R))) +if (isSomeString!R && is(RegEx == Regex!(BasicElementOf!R))) { import std.regex.internal.thompson : ThompsonMatcher; return matchMany!ThompsonMatcher(input, re); @@ -993,7 +993,7 @@ public auto matchAll(R, RegEx)(R input, RegEx re) ///ditto public auto matchAll(R, String)(R input, String re) - if (isSomeString!R && isSomeString!String) +if (isSomeString!R && isSomeString!String) { import std.regex.internal.thompson : ThompsonMatcher; return matchMany!ThompsonMatcher(input, regex(re)); @@ -1001,14 +1001,14 @@ public auto matchAll(R, String)(R input, String re) ///ditto public auto matchAll(R, String)(R input, String[] re...) - if (isSomeString!R && isSomeString!String) +if (isSomeString!R && isSomeString!String) { import std.regex.internal.thompson : ThompsonMatcher; return matchMany!ThompsonMatcher(input, regex(re)); } public auto matchAll(R, RegEx)(R input, RegEx re) - if (isSomeString!R && is(RegEx == StaticRegex!(BasicElementOf!R))) +if (isSomeString!R && is(RegEx == StaticRegex!(BasicElementOf!R))) { import std.regex.internal.backtracking : BacktrackingMatcher; return matchMany!(BacktrackingMatcher!true)(input, re); @@ -1074,7 +1074,7 @@ public auto matchAll(R, RegEx)(R input, RegEx re) +/ public auto bmatch(R, RegEx)(R input, RegEx re) - if (isSomeString!R && is(RegEx == Regex!(BasicElementOf!R))) +if (isSomeString!R && is(RegEx == Regex!(BasicElementOf!R))) { import std.regex.internal.backtracking : BacktrackingMatcher; return RegexMatch!(Unqual!(typeof(input)), BacktrackingMatcher!false)(input, re); @@ -1082,14 +1082,14 @@ public auto bmatch(R, RegEx)(R input, RegEx re) ///ditto public auto bmatch(R, String)(R input, String re) - if (isSomeString!R && isSomeString!String) +if (isSomeString!R && isSomeString!String) { import std.regex.internal.backtracking : BacktrackingMatcher; return RegexMatch!(Unqual!(typeof(input)), BacktrackingMatcher!false)(input, regex(re)); } public auto bmatch(R, RegEx)(R input, RegEx re) - if (isSomeString!R && is(RegEx == StaticRegex!(BasicElementOf!R))) +if (isSomeString!R && is(RegEx == StaticRegex!(BasicElementOf!R))) { import std.regex.internal.backtracking : BacktrackingMatcher; return RegexMatch!(Unqual!(typeof(input)),BacktrackingMatcher!true)(input, re); @@ -1098,8 +1098,8 @@ public auto bmatch(R, RegEx)(R input, RegEx re) // produces replacement string from format using captures for substitution package void replaceFmt(R, Capt, OutR) (R format, Capt captures, OutR sink, bool ignoreBadSubs = false) - if (isOutputRange!(OutR, ElementEncodingType!R[]) && - isOutputRange!(OutR, ElementEncodingType!(Capt.String)[])) +if (isOutputRange!(OutR, ElementEncodingType!R[]) && + isOutputRange!(OutR, ElementEncodingType!(Capt.String)[])) { import std.algorithm.searching : find; import std.conv : text, parse; @@ -1186,7 +1186,7 @@ L_Replace_Loop: If no match is found returns the input string itself. +/ public R replaceFirst(R, C, RegEx)(R input, RegEx re, const(C)[] format) - if (isSomeString!R && is(C : dchar) && isRegexFor!(RegEx, R)) +if (isSomeString!R && is(C : dchar) && isRegexFor!(RegEx, R)) { return replaceFirstWith!((m, sink) => replaceFmt(format, m, sink))(input, re); } @@ -1213,7 +1213,7 @@ unittest returns the $(D input) itself. +/ public R replaceFirst(alias fun, R, RegEx)(R input, RegEx re) - if (isSomeString!R && isRegexFor!(RegEx, R)) +if (isSomeString!R && isRegexFor!(RegEx, R)) { return replaceFirstWith!((m, sink) => sink.put(fun(m)))(input, re); } @@ -1239,8 +1239,8 @@ unittest +/ public @trusted void replaceFirstInto(Sink, R, C, RegEx) (ref Sink sink, R input, RegEx re, const(C)[] format) - if (isOutputRange!(Sink, dchar) && isSomeString!R - && is(C : dchar) && isRegexFor!(RegEx, R)) +if (isOutputRange!(Sink, dchar) && isSomeString!R + && is(C : dchar) && isRegexFor!(RegEx, R)) { replaceCapturesInto!((m, sink) => replaceFmt(format, m, sink)) (sink, input, matchFirst(input, re)); @@ -1249,7 +1249,7 @@ public @trusted void replaceFirstInto(Sink, R, C, RegEx) ///ditto public @trusted void replaceFirstInto(alias fun, Sink, R, RegEx) (Sink sink, R input, RegEx re) - if (isOutputRange!(Sink, dchar) && isSomeString!R && isRegexFor!(RegEx, R)) +if (isOutputRange!(Sink, dchar) && isSomeString!R && isRegexFor!(RegEx, R)) { replaceCapturesInto!fun(sink, input, matchFirst(input, re)); } @@ -1304,7 +1304,7 @@ unittest If no match is found returns the input string itself. +/ public @trusted R replaceAll(R, C, RegEx)(R input, RegEx re, const(C)[] format) - if (isSomeString!R && is(C : dchar) && isRegexFor!(RegEx, R)) +if (isSomeString!R && is(C : dchar) && isRegexFor!(RegEx, R)) { return replaceAllWith!((m, sink) => replaceFmt(format, m, sink))(input, re); } @@ -1338,7 +1338,7 @@ unittest fun = delegate to use +/ public @trusted R replaceAll(alias fun, R, RegEx)(R input, RegEx re) - if (isSomeString!R && isRegexFor!(RegEx, R)) +if (isSomeString!R && isRegexFor!(RegEx, R)) { return replaceAllWith!((m, sink) => sink.put(fun(m)))(input, re); } @@ -1367,8 +1367,8 @@ unittest +/ public @trusted void replaceAllInto(Sink, R, C, RegEx) (Sink sink, R input, RegEx re, const(C)[] format) - if (isOutputRange!(Sink, dchar) && isSomeString!R - && is(C : dchar) && isRegexFor!(RegEx, R)) +if (isOutputRange!(Sink, dchar) && isSomeString!R + && is(C : dchar) && isRegexFor!(RegEx, R)) { replaceMatchesInto!((m, sink) => replaceFmt(format, m, sink)) (sink, input, matchAll(input, re)); @@ -1377,7 +1377,7 @@ public @trusted void replaceAllInto(Sink, R, C, RegEx) ///ditto public @trusted void replaceAllInto(alias fun, Sink, R, RegEx) (Sink sink, R input, RegEx re) - if (isOutputRange!(Sink, dchar) && isSomeString!R && isRegexFor!(RegEx, R)) +if (isOutputRange!(Sink, dchar) && isSomeString!R && isRegexFor!(RegEx, R)) { replaceMatchesInto!fun(sink, input, matchAll(input, re)); } @@ -1449,14 +1449,14 @@ public @trusted void replaceAllInto(alias fun, Sink, R, RegEx) or $(LREF replaceFirst) explicitly. +/ public R replace(alias scheme = match, R, C, RegEx)(R input, RegEx re, const(C)[] format) - if (isSomeString!R && isRegexFor!(RegEx, R)) +if (isSomeString!R && isRegexFor!(RegEx, R)) { return replaceAllWith!((m, sink) => replaceFmt(format, m, sink), match)(input, re); } ///ditto public R replace(alias fun, R, RegEx)(R input, RegEx re) - if (isSomeString!R && isRegexFor!(RegEx, R)) +if (isSomeString!R && isRegexFor!(RegEx, R)) { return replaceAllWith!(fun, match)(input, re); } @@ -1472,7 +1472,7 @@ Returns: A lazy range of strings */ public struct Splitter(Flag!"keepSeparators" keepSeparators = No.keepSeparators, Range, alias RegEx = Regex) - if (isSomeString!Range && isRegexFor!(RegEx, Range)) +if (isSomeString!Range && isRegexFor!(RegEx, Range)) { private: Range _input; @@ -1581,8 +1581,9 @@ public: /// ditto public Splitter!(keepSeparators, Range, RegEx) splitter( - Flag!"keepSeparators" keepSeparators = No.keepSeparators, Range, RegEx)(Range r, RegEx pat) if ( - is(BasicElementOf!Range : dchar) && isRegexFor!(RegEx, Range)) + Flag!"keepSeparators" keepSeparators = No.keepSeparators, Range, RegEx)(Range r, RegEx pat) +if ( + is(BasicElementOf!Range : dchar) && isRegexFor!(RegEx, Range)) { return Splitter!(keepSeparators, Range, RegEx)(r, pat); } @@ -1615,7 +1616,7 @@ unittest ///An eager version of $(D splitter) that creates an array with splitted slices of $(D input). public @trusted String[] split(String, RegEx)(String input, RegEx rx) - if (isSomeString!String && isRegexFor!(RegEx, String)) +if (isSomeString!String && isRegexFor!(RegEx, String)) { import std.array : appender; auto a = appender!(String[])(); diff --git a/std/stdio.d b/std/stdio.d index 4aeccd301..24b68ec7c 100644 --- a/std/stdio.d +++ b/std/stdio.d @@ -3401,7 +3401,8 @@ void main() } --- */ -void write(T...)(T args) if (!is(T[0] : File)) +void write(T...)(T args) +if (!is(T[0] : File)) { trustedStdout.write(args); } @@ -3809,8 +3810,8 @@ if (isSomeChar!C && is(Unqual!C == C) && !is(C == enum) && * with appropriately-constructed C-style strings. */ private FILE* fopen(R1, R2)(R1 name, R2 mode = "r") - if ((isInputRange!R1 && isSomeChar!(ElementEncodingType!R1) || isSomeString!R1) && - (isInputRange!R2 && isSomeChar!(ElementEncodingType!R2) || isSomeString!R2)) +if ((isInputRange!R1 && isSomeChar!(ElementEncodingType!R1) || isSomeString!R1) && + (isInputRange!R2 && isSomeChar!(ElementEncodingType!R2) || isSomeString!R2)) { import std.internal.cstring : tempCString; @@ -3851,8 +3852,8 @@ version (Posix) * with appropriately-constructed C-style strings. */ FILE* popen(R1, R2)(R1 name, R2 mode = "r") @trusted nothrow @nogc - if ((isInputRange!R1 && isSomeChar!(ElementEncodingType!R1) || isSomeString!R1) && - (isInputRange!R2 && isSomeChar!(ElementEncodingType!R2) || isSomeString!R2)) + if ((isInputRange!R1 && isSomeChar!(ElementEncodingType!R1) || isSomeString!R1) && + (isInputRange!R2 && isSomeChar!(ElementEncodingType!R2) || isSomeString!R2)) { import std.internal.cstring : tempCString; @@ -4277,7 +4278,7 @@ en.cppreference.com/w/c/io#Narrow_and_wide_orientation, orientation). */ void toFile(T)(T data, string fileName) - if (is(typeof(copy(data, stdout.lockingBinaryWriter)))) +if (is(typeof(copy(data, stdout.lockingBinaryWriter)))) { copy(data, File(fileName, "wb").lockingBinaryWriter); } diff --git a/std/string.d b/std/string.d index 8be9c9a72..c4a61e1f6 100644 --- a/std/string.d +++ b/std/string.d @@ -373,8 +373,8 @@ alias CaseSensitive = Flag!"caseSensitive"; +/ ptrdiff_t indexOf(Range)(Range s, in dchar c, in CaseSensitive cs = Yes.caseSensitive) - if (isInputRange!Range && isSomeChar!(ElementEncodingType!Range) && - !isConvertibleToString!Range) +if (isInputRange!Range && isSomeChar!(ElementEncodingType!Range) && + !isConvertibleToString!Range) { static import std.ascii; static import std.uni; @@ -501,8 +501,8 @@ ptrdiff_t indexOf(Range)(Range s, in dchar c, /// Ditto ptrdiff_t indexOf(Range)(Range s, in dchar c, in size_t startIdx, in CaseSensitive cs = Yes.caseSensitive) - if (isInputRange!Range && isSomeChar!(ElementEncodingType!Range) && - !isConvertibleToString!Range) +if (isInputRange!Range && isSomeChar!(ElementEncodingType!Range) && + !isConvertibleToString!Range) { static if (isSomeString!(typeof(s)) || (hasSlicing!(typeof(s)) && hasLength!(typeof(s)))) @@ -557,14 +557,14 @@ ptrdiff_t indexOf(Range)(Range s, in dchar c, in size_t startIdx, ptrdiff_t indexOf(Range)(auto ref Range s, in dchar c, in CaseSensitive cs = Yes.caseSensitive) - if (isConvertibleToString!Range) +if (isConvertibleToString!Range) { return indexOf!(StringTypeOf!Range)(s, c, cs); } ptrdiff_t indexOf(Range)(auto ref Range s, in dchar c, in size_t startIdx, in CaseSensitive cs = Yes.caseSensitive) - if (isConvertibleToString!Range) +if (isConvertibleToString!Range) { return indexOf!(StringTypeOf!Range)(s, c, startIdx, cs); } @@ -706,8 +706,8 @@ ptrdiff_t indexOf(Range)(auto ref Range s, in dchar c, in size_t startIdx, +/ ptrdiff_t indexOf(Range, Char)(Range s, const(Char)[] sub, in CaseSensitive cs = Yes.caseSensitive) - if (isForwardRange!Range && isSomeChar!(ElementEncodingType!Range) && - isSomeChar!Char) +if (isForwardRange!Range && isSomeChar!(ElementEncodingType!Range) && + isSomeChar!Char) { alias Char1 = Unqual!(ElementEncodingType!Range); @@ -780,7 +780,8 @@ ptrdiff_t indexOf(Range, Char)(Range s, const(Char)[] sub, /// Ditto ptrdiff_t indexOf(Char1, Char2)(const(Char1)[] s, const(Char2)[] sub, in size_t startIdx, in CaseSensitive cs = Yes.caseSensitive) - @safe if (isSomeChar!Char1 && isSomeChar!Char2) +@safe +if (isSomeChar!Char1 && isSomeChar!Char2) { if (startIdx < s.length) { @@ -817,9 +818,9 @@ ptrdiff_t indexOf(Char1, Char2)(const(Char1)[] s, const(Char2)[] sub, ptrdiff_t indexOf(Range, Char)(auto ref Range s, const(Char)[] sub, in CaseSensitive cs = Yes.caseSensitive) - if (!(isForwardRange!Range && isSomeChar!(ElementEncodingType!Range) && - isSomeChar!Char) && - is(StringTypeOf!Range)) +if (!(isForwardRange!Range && isSomeChar!(ElementEncodingType!Range) && + isSomeChar!Char) && + is(StringTypeOf!Range)) { return indexOf!(StringTypeOf!Range)(s, sub, cs); } @@ -982,7 +983,7 @@ unittest +/ ptrdiff_t lastIndexOf(Char)(const(Char)[] s, in dchar c, in CaseSensitive cs = Yes.caseSensitive) @safe pure - if (isSomeChar!Char) +if (isSomeChar!Char) { static import std.ascii, std.uni; import std.utf : canSearchInCodeUnits; @@ -1045,7 +1046,7 @@ ptrdiff_t lastIndexOf(Char)(const(Char)[] s, in dchar c, /// Ditto ptrdiff_t lastIndexOf(Char)(const(Char)[] s, in dchar c, in size_t startIdx, in CaseSensitive cs = Yes.caseSensitive) @safe pure - if (isSomeChar!Char) +if (isSomeChar!Char) { if (startIdx <= s.length) { @@ -1174,7 +1175,7 @@ ptrdiff_t lastIndexOf(Char)(const(Char)[] s, in dchar c, in size_t startIdx, +/ ptrdiff_t lastIndexOf(Char1, Char2)(const(Char1)[] s, const(Char2)[] sub, in CaseSensitive cs = Yes.caseSensitive) @safe pure - if (isSomeChar!Char1 && isSomeChar!Char2) +if (isSomeChar!Char1 && isSomeChar!Char2) { import std.algorithm.searching : endsWith; import std.conv : to; @@ -1254,7 +1255,7 @@ ptrdiff_t lastIndexOf(Char1, Char2)(const(Char1)[] s, const(Char2)[] sub, /// Ditto ptrdiff_t lastIndexOf(Char1, Char2)(const(Char1)[] s, const(Char2)[] sub, in size_t startIdx, in CaseSensitive cs = Yes.caseSensitive) @safe pure - if (isSomeChar!Char1 && isSomeChar!Char2) +if (isSomeChar!Char1 && isSomeChar!Char2) { if (startIdx <= s.length) { @@ -1436,7 +1437,7 @@ ptrdiff_t lastIndexOf(Char1, Char2)(const(Char1)[] s, const(Char2)[] sub, private ptrdiff_t indexOfAnyNeitherImpl(bool forward, bool any, Char, Char2)( const(Char)[] haystack, const(Char2)[] needles, in CaseSensitive cs = Yes.caseSensitive) @safe pure - if (isSomeChar!Char && isSomeChar!Char2) +if (isSomeChar!Char && isSomeChar!Char2) { import std.algorithm.searching : canFind, findAmong; if (cs == Yes.caseSensitive) @@ -1568,7 +1569,7 @@ private ptrdiff_t indexOfAnyNeitherImpl(bool forward, bool any, Char, Char2)( */ ptrdiff_t indexOfAny(Char,Char2)(const(Char)[] haystack, const(Char2)[] needles, in CaseSensitive cs = Yes.caseSensitive) @safe pure - if (isSomeChar!Char && isSomeChar!Char2) +if (isSomeChar!Char && isSomeChar!Char2) { return indexOfAnyNeitherImpl!(true, true)(haystack, needles, cs); } @@ -1576,7 +1577,7 @@ ptrdiff_t indexOfAny(Char,Char2)(const(Char)[] haystack, const(Char2)[] needles, /// Ditto ptrdiff_t indexOfAny(Char,Char2)(const(Char)[] haystack, const(Char2)[] needles, in size_t startIdx, in CaseSensitive cs = Yes.caseSensitive) @safe pure - if (isSomeChar!Char && isSomeChar!Char2) +if (isSomeChar!Char && isSomeChar!Char2) { if (startIdx < haystack.length) { @@ -1740,7 +1741,7 @@ ptrdiff_t indexOfAny(Char,Char2)(const(Char)[] haystack, const(Char2)[] needles, ptrdiff_t lastIndexOfAny(Char,Char2)(const(Char)[] haystack, const(Char2)[] needles, in CaseSensitive cs = Yes.caseSensitive) @safe pure - if (isSomeChar!Char && isSomeChar!Char2) +if (isSomeChar!Char && isSomeChar!Char2) { return indexOfAnyNeitherImpl!(false, true)(haystack, needles, cs); } @@ -1749,7 +1750,7 @@ ptrdiff_t lastIndexOfAny(Char,Char2)(const(Char)[] haystack, ptrdiff_t lastIndexOfAny(Char,Char2)(const(Char)[] haystack, const(Char2)[] needles, in size_t stopIdx, in CaseSensitive cs = Yes.caseSensitive) @safe pure - if (isSomeChar!Char && isSomeChar!Char2) +if (isSomeChar!Char && isSomeChar!Char2) { if (stopIdx <= haystack.length) { @@ -1923,7 +1924,7 @@ ptrdiff_t lastIndexOfAny(Char,Char2)(const(Char)[] haystack, ptrdiff_t indexOfNeither(Char,Char2)(const(Char)[] haystack, const(Char2)[] needles, in CaseSensitive cs = Yes.caseSensitive) @safe pure - if (isSomeChar!Char && isSomeChar!Char2) +if (isSomeChar!Char && isSomeChar!Char2) { return indexOfAnyNeitherImpl!(true, false)(haystack, needles, cs); } @@ -1933,7 +1934,7 @@ ptrdiff_t indexOfNeither(Char,Char2)(const(Char)[] haystack, const(Char2)[] needles, in size_t startIdx, in CaseSensitive cs = Yes.caseSensitive) @safe pure - if (isSomeChar!Char && isSomeChar!Char2) +if (isSomeChar!Char && isSomeChar!Char2) { if (startIdx < haystack.length) { @@ -2087,7 +2088,7 @@ ptrdiff_t indexOfNeither(Char,Char2)(const(Char)[] haystack, ptrdiff_t lastIndexOfNeither(Char,Char2)(const(Char)[] haystack, const(Char2)[] needles, in CaseSensitive cs = Yes.caseSensitive) @safe pure - if (isSomeChar!Char && isSomeChar!Char2) +if (isSomeChar!Char && isSomeChar!Char2) { return indexOfAnyNeitherImpl!(false, false)(haystack, needles, cs); } @@ -2097,7 +2098,7 @@ ptrdiff_t lastIndexOfNeither(Char,Char2)(const(Char)[] haystack, const(Char2)[] needles, in size_t stopIdx, in CaseSensitive cs = Yes.caseSensitive) @safe pure - if (isSomeChar!Char && isSomeChar!Char2) +if (isSomeChar!Char && isSomeChar!Char2) { if (stopIdx < haystack.length) { @@ -2243,7 +2244,7 @@ ptrdiff_t lastIndexOfNeither(Char,Char2)(const(Char)[] haystack, * The _representation of the passed string. */ auto representation(Char)(Char[] s) @safe pure nothrow @nogc - if (isSomeChar!Char) +if (isSomeChar!Char) { import std.traits : ModifyTypePreservingTQ; alias ToRepType(T) = AliasSeq!(ubyte, ushort, uint)[T.sizeof / 2]; @@ -2305,7 +2306,7 @@ auto representation(Char)(Char[] s) @safe pure nothrow @nogc * $(REF asCapitalized, std,uni) for a lazy range version that doesn't allocate memory */ S capitalize(S)(S input) @trusted pure - if (isSomeString!S) +if (isSomeString!S) { import std.array : array; import std.conv : to; @@ -2322,7 +2323,7 @@ pure @safe unittest } auto capitalize(S)(auto ref S s) - if (!isSomeString!S && is(StringTypeOf!S)) +if (!isSomeString!S && is(StringTypeOf!S)) { return capitalize!(StringTypeOf!S)(s); } @@ -2399,7 +2400,7 @@ alias KeepTerminator = Flag!"keepTerminator"; /// ditto S[] splitLines(S)(S s, in KeepTerminator keepTerm = No.keepTerminator) @safe pure - if (isSomeString!S) +if (isSomeString!S) { import std.array : appender; import std.uni : lineSep, paraSep; @@ -2495,7 +2496,7 @@ S[] splitLines(S)(S s, in KeepTerminator keepTerm = No.keepTerminator) @safe pur } auto splitLines(S)(auto ref S s, in KeepTerminator keepTerm = No.keepTerminator) - if (!isSomeString!S && is(StringTypeOf!S)) +if (!isSomeString!S && is(StringTypeOf!S)) { return splitLines!(StringTypeOf!S)(s, keepTerm); } @@ -2729,9 +2730,9 @@ public: $(REF splitter, std,regex) */ auto lineSplitter(KeepTerminator keepTerm = No.keepTerminator, Range)(Range r) - if ((hasSlicing!Range && hasLength!Range && isSomeChar!(ElementType!Range) || - isSomeString!Range) && - !isConvertibleToString!Range) +if ((hasSlicing!Range && hasLength!Range && isSomeChar!(ElementType!Range) || + isSomeString!Range) && + !isConvertibleToString!Range) { return LineSplitter!(keepTerm, Range)(r); } @@ -2750,7 +2751,7 @@ auto lineSplitter(KeepTerminator keepTerm = No.keepTerminator, Range)(Range r) } auto lineSplitter(KeepTerminator keepTerm = No.keepTerminator, Range)(auto ref Range r) - if (isConvertibleToString!Range) +if (isConvertibleToString!Range) { return LineSplitter!(keepTerm, StringTypeOf!Range)(r); } @@ -2871,8 +2872,8 @@ auto lineSplitter(KeepTerminator keepTerm = No.keepTerminator, Range)(auto ref R Generic stripping on ranges: $(REF _stripLeft, std, algorithm, mutation) +/ auto stripLeft(Range)(Range input) - if (isForwardRange!Range && isSomeChar!(ElementEncodingType!Range) && - !isInfinite!Range && !isConvertibleToString!Range) +if (isForwardRange!Range && isSomeChar!(ElementEncodingType!Range) && + !isInfinite!Range && !isConvertibleToString!Range) { static import std.ascii; static import std.uni; @@ -2920,7 +2921,7 @@ auto stripLeft(Range)(Range input) } auto stripLeft(Range)(auto ref Range str) - if (isConvertibleToString!Range) +if (isConvertibleToString!Range) { return stripLeft!(StringTypeOf!Range)(str); } @@ -2943,10 +2944,10 @@ auto stripLeft(Range)(auto ref Range str) Generic stripping on ranges: $(REF _stripRight, std, algorithm, mutation) +/ auto stripRight(Range)(Range str) - if (isSomeString!Range || - isRandomAccessRange!Range && hasLength!Range && hasSlicing!Range && - !isConvertibleToString!Range && - isSomeChar!(ElementEncodingType!Range)) +if (isSomeString!Range || + isRandomAccessRange!Range && hasLength!Range && hasSlicing!Range && + !isConvertibleToString!Range && + isSomeChar!(ElementEncodingType!Range)) { import std.uni : isWhite; alias C = Unqual!(ElementEncodingType!(typeof(str))); @@ -3056,7 +3057,7 @@ unittest } auto stripRight(Range)(auto ref Range str) - if (isConvertibleToString!Range) +if (isConvertibleToString!Range) { return stripRight!(StringTypeOf!Range)(str); } @@ -3105,10 +3106,10 @@ auto stripRight(Range)(auto ref Range str) Generic stripping on ranges: $(REF _strip, std, algorithm, mutation) +/ auto strip(Range)(Range str) - if (isSomeString!Range || - isRandomAccessRange!Range && hasLength!Range && hasSlicing!Range && - !isConvertibleToString!Range && - isSomeChar!(ElementEncodingType!Range)) +if (isSomeString!Range || + isRandomAccessRange!Range && hasLength!Range && hasSlicing!Range && + !isConvertibleToString!Range && + isSomeChar!(ElementEncodingType!Range)) { return stripRight(stripLeft(str)); } @@ -3130,7 +3131,7 @@ auto strip(Range)(Range str) } auto strip(Range)(auto ref Range str) - if (isConvertibleToString!Range) +if (isConvertibleToString!Range) { return strip!(StringTypeOf!Range)(str); } @@ -3208,9 +3209,9 @@ auto strip(Range)(auto ref Range str) slice of str +/ Range chomp(Range)(Range str) - if ((isRandomAccessRange!Range && isSomeChar!(ElementEncodingType!Range) || - isNarrowString!Range) && - !isConvertibleToString!Range) +if ((isRandomAccessRange!Range && isSomeChar!(ElementEncodingType!Range) || + isNarrowString!Range) && + !isConvertibleToString!Range) { import std.uni : lineSep, paraSep, nelSep; if (str.empty) @@ -3264,10 +3265,10 @@ Range chomp(Range)(Range str) /// Ditto Range chomp(Range, C2)(Range str, const(C2)[] delimiter) - if ((isBidirectionalRange!Range && isSomeChar!(ElementEncodingType!Range) || - isNarrowString!Range) && - !isConvertibleToString!Range && - isSomeChar!C2) +if ((isBidirectionalRange!Range && isSomeChar!(ElementEncodingType!Range) || + isNarrowString!Range) && + !isConvertibleToString!Range && + isSomeChar!C2) { if (delimiter.empty) return chomp(str); @@ -3329,13 +3330,13 @@ unittest } StringTypeOf!Range chomp(Range)(auto ref Range str) - if (isConvertibleToString!Range) +if (isConvertibleToString!Range) { return chomp!(StringTypeOf!Range)(str); } StringTypeOf!Range chomp(Range, C2)(auto ref Range str, const(C2)[] delimiter) - if (isConvertibleToString!Range) +if (isConvertibleToString!Range) { return chomp!(StringTypeOf!Range, C2)(str, delimiter); } @@ -3420,10 +3421,10 @@ StringTypeOf!Range chomp(Range, C2)(auto ref Range str, const(C2)[] delimiter) slice of str +/ Range chompPrefix(Range, C2)(Range str, const(C2)[] delimiter) - if ((isForwardRange!Range && isSomeChar!(ElementEncodingType!Range) || - isNarrowString!Range) && - !isConvertibleToString!Range && - isSomeChar!C2) +if ((isForwardRange!Range && isSomeChar!(ElementEncodingType!Range) || + isNarrowString!Range) && + !isConvertibleToString!Range && + isSomeChar!C2) { alias C1 = ElementEncodingType!Range; @@ -3465,7 +3466,7 @@ Range chompPrefix(Range, C2)(Range str, const(C2)[] delimiter) } StringTypeOf!Range chompPrefix(Range, C2)(auto ref Range str, const(C2)[] delimiter) - if (isConvertibleToString!Range) +if (isConvertibleToString!Range) { return chompPrefix!(StringTypeOf!Range, C2)(str, delimiter); } @@ -3523,9 +3524,9 @@ unittest +/ Range chop(Range)(Range str) - if ((isBidirectionalRange!Range && isSomeChar!(ElementEncodingType!Range) || - isNarrowString!Range) && - !isConvertibleToString!Range) +if ((isBidirectionalRange!Range && isSomeChar!(ElementEncodingType!Range) || + isNarrowString!Range) && + !isConvertibleToString!Range) { if (str.empty) return str; @@ -3592,7 +3593,7 @@ Range chop(Range)(Range str) } StringTypeOf!Range chop(Range)(auto ref Range str) - if (isConvertibleToString!Range) +if (isConvertibleToString!Range) { return chop!(StringTypeOf!Range)(str); } @@ -3677,7 +3678,7 @@ StringTypeOf!Range chop(Range)(auto ref Range str) $(LREF leftJustifier), which does not allocate +/ S leftJustify(S)(S s, size_t width, dchar fillChar = ' ') - if (isSomeString!S) +if (isSomeString!S) { import std.array : array; return leftJustifier(s, width, fillChar).array; @@ -3709,8 +3710,8 @@ S leftJustify(S)(S s, size_t width, dchar fillChar = ' ') +/ auto leftJustifier(Range)(Range r, size_t width, dchar fillChar = ' ') - if (isInputRange!Range && isSomeChar!(ElementEncodingType!Range) && - !isConvertibleToString!Range) +if (isInputRange!Range && isSomeChar!(ElementEncodingType!Range) && + !isConvertibleToString!Range) { alias C = Unqual!(ElementEncodingType!Range); @@ -3782,7 +3783,7 @@ unittest } auto leftJustifier(Range)(auto ref Range r, size_t width, dchar fillChar = ' ') - if (isConvertibleToString!Range) +if (isConvertibleToString!Range) { return leftJustifier!(StringTypeOf!Range)(r, width, fillChar); } @@ -3819,7 +3820,7 @@ auto leftJustifier(Range)(auto ref Range r, size_t width, dchar fillChar = ' ') $(LREF rightJustifier), which does not allocate +/ S rightJustify(S)(S s, size_t width, dchar fillChar = ' ') - if (isSomeString!S) +if (isSomeString!S) { import std.array : array; return rightJustifier(s, width, fillChar).array; @@ -3851,8 +3852,8 @@ S rightJustify(S)(S s, size_t width, dchar fillChar = ' ') +/ auto rightJustifier(Range)(Range r, size_t width, dchar fillChar = ' ') - if (isForwardRange!Range && isSomeChar!(ElementEncodingType!Range) && - !isConvertibleToString!Range) +if (isForwardRange!Range && isSomeChar!(ElementEncodingType!Range) && + !isConvertibleToString!Range) { alias C = Unqual!(ElementEncodingType!Range); @@ -3961,7 +3962,7 @@ unittest } auto rightJustifier(Range)(auto ref Range r, size_t width, dchar fillChar = ' ') - if (isConvertibleToString!Range) +if (isConvertibleToString!Range) { return rightJustifier!(StringTypeOf!Range)(r, width, fillChar); } @@ -4008,7 +4009,7 @@ auto rightJustifier(Range)(auto ref Range r, size_t width, dchar fillChar = ' ') instead. +/ S center(S)(S s, size_t width, dchar fillChar = ' ') - if (isSomeString!S) +if (isSomeString!S) { import std.array : array; return centerJustifier(s, width, fillChar).array; @@ -4078,8 +4079,8 @@ unittest +/ auto centerJustifier(Range)(Range r, size_t width, dchar fillChar = ' ') - if (isForwardRange!Range && isSomeChar!(ElementEncodingType!Range) && - !isConvertibleToString!Range) +if (isForwardRange!Range && isSomeChar!(ElementEncodingType!Range) && + !isConvertibleToString!Range) { alias C = Unqual!(ElementEncodingType!Range); @@ -4121,7 +4122,7 @@ unittest } auto centerJustifier(Range)(auto ref Range r, size_t width, dchar fillChar = ' ') - if (isConvertibleToString!Range) +if (isConvertibleToString!Range) { return centerJustifier!(StringTypeOf!Range)(r, width, fillChar); } @@ -4182,8 +4183,8 @@ auto centerJustifier(Range)(auto ref Range r, size_t width, dchar fillChar = ' ' GC allocated string with tabs replaced with spaces +/ auto detab(Range)(auto ref Range s, size_t tabSize = 8) pure - if ((isForwardRange!Range && isSomeChar!(ElementEncodingType!Range)) - || __traits(compiles, StringTypeOf!Range)) +if ((isForwardRange!Range && isSomeChar!(ElementEncodingType!Range)) + || __traits(compiles, StringTypeOf!Range)) { import std.array : array; return detabber(s, tabSize).array; @@ -4232,8 +4233,8 @@ auto detab(Range)(auto ref Range s, size_t tabSize = 8) pure lazy forward range with tabs replaced with spaces +/ auto detabber(Range)(Range r, size_t tabSize = 8) - if (isForwardRange!Range && isSomeChar!(ElementEncodingType!Range) && - !isConvertibleToString!Range) +if (isForwardRange!Range && isSomeChar!(ElementEncodingType!Range) && + !isConvertibleToString!Range) { import std.uni : lineSep, paraSep, nelSep; import std.utf : codeUnitLimit, decodeFront; @@ -4351,7 +4352,7 @@ auto detabber(Range)(Range r, size_t tabSize = 8) } auto detabber(Range)(auto ref Range r, size_t tabSize = 8) - if (isConvertibleToString!Range) +if (isConvertibleToString!Range) { return detabber!(StringTypeOf!Range)(r, tabSize); } @@ -4425,7 +4426,7 @@ auto detabber(Range)(auto ref Range r, size_t tabSize = 8) $(LREF entabber) +/ auto entab(Range)(Range s, size_t tabSize = 8) - if (isForwardRange!Range && isSomeChar!(ElementEncodingType!Range)) +if (isForwardRange!Range && isSomeChar!(ElementEncodingType!Range)) { import std.array : array; return entabber(s, tabSize).array; @@ -4438,8 +4439,8 @@ auto entab(Range)(Range s, size_t tabSize = 8) } auto entab(Range)(auto ref Range s, size_t tabSize = 8) - if (!(isForwardRange!Range && isSomeChar!(ElementEncodingType!Range)) && - is(StringTypeOf!Range)) +if (!(isForwardRange!Range && isSomeChar!(ElementEncodingType!Range)) && + is(StringTypeOf!Range)) { return entab!(StringTypeOf!Range)(s, tabSize); } @@ -4464,7 +4465,7 @@ auto entab(Range)(auto ref Range s, size_t tabSize = 8) $(LREF entab) +/ auto entabber(Range)(Range r, size_t tabSize = 8) - if (isForwardRange!Range && !isConvertibleToString!Range) +if (isForwardRange!Range && !isConvertibleToString!Range) { import std.uni : lineSep, paraSep, nelSep; import std.utf : codeUnitLimit, decodeFront; @@ -4690,7 +4691,7 @@ auto entabber(Range)(Range r, size_t tabSize = 8) } auto entabber(Range)(auto ref Range r, size_t tabSize = 8) - if (isConvertibleToString!Range) +if (isConvertibleToString!Range) { return entabber!(StringTypeOf!Range)(r, tabSize); } @@ -4787,7 +4788,7 @@ unittest C1[] translate(C1, C2 = immutable char)(C1[] str, in dchar[dchar] transTable, const(C2)[] toRemove = null) @safe pure - if (isSomeChar!C1 && isSomeChar!C2) +if (isSomeChar!C1 && isSomeChar!C2) { import std.array : appender; auto buffer = appender!(C1[])(); @@ -4867,7 +4868,7 @@ C1[] translate(C1, C2 = immutable char)(C1[] str, C1[] translate(C1, S, C2 = immutable char)(C1[] str, in S[dchar] transTable, const(C2)[] toRemove = null) @safe pure - if (isSomeChar!C1 && isSomeString!S && isSomeChar!C2) +if (isSomeChar!C1 && isSomeString!S && isSomeChar!C2) { import std.array : appender; auto buffer = appender!(C1[])(); @@ -4943,7 +4944,7 @@ void translate(C1, C2 = immutable char, Buffer)(C1[] str, in dchar[dchar] transTable, const(C2)[] toRemove, Buffer buffer) - if (isSomeChar!C1 && isSomeChar!C2 && isOutputRange!(Buffer, C1)) +if (isSomeChar!C1 && isSomeChar!C2 && isOutputRange!(Buffer, C1)) { translateImpl(str, transTable, toRemove, buffer); } @@ -4990,7 +4991,7 @@ void translate(C1, S, C2 = immutable char, Buffer)(C1[] str, in S[dchar] transTable, const(C2)[] toRemove, Buffer buffer) - if (isSomeChar!C1 && isSomeString!S && isSomeChar!C2 && isOutputRange!(Buffer, S)) +if (isSomeChar!C1 && isSomeString!S && isSomeChar!C2 && isOutputRange!(Buffer, S)) { translateImpl(str, transTable, toRemove, buffer); } @@ -5053,7 +5054,7 @@ private void translateImpl(C1, T, C2, Buffer)(C1[] str, toRemove = The characters to remove from the string. +/ C[] translate(C = immutable char)(in char[] str, in char[] transTable, in char[] toRemove = null) @trusted pure nothrow - if (is(Unqual!C == char)) +if (is(Unqual!C == char)) in { assert(transTable.length == 256); @@ -5192,7 +5193,7 @@ body +/ void translate(C = immutable char, Buffer)(in char[] str, in char[] transTable, in char[] toRemove, Buffer buffer) @trusted pure - if (is(Unqual!C == char) && isOutputRange!(Buffer, char)) +if (is(Unqual!C == char) && isOutputRange!(Buffer, char)) in { assert(transTable.length == 256); @@ -5244,7 +5245,8 @@ body * to be more like regular expression character classes. */ -bool inPattern(S)(dchar c, in S pattern) @safe pure @nogc if (isSomeString!S) +bool inPattern(S)(dchar c, in S pattern) @safe pure @nogc +if (isSomeString!S) { bool result = false; int range = 0; @@ -5313,7 +5315,8 @@ bool inPattern(S)(dchar c, in S pattern) @safe pure @nogc if (isSomeString!S) * See if character c is in the intersection of the patterns. */ -bool inPattern(S)(dchar c, S[] patterns) @safe pure @nogc if (isSomeString!S) +bool inPattern(S)(dchar c, S[] patterns) @safe pure @nogc +if (isSomeString!S) { foreach (string pattern; patterns) { @@ -5330,7 +5333,8 @@ bool inPattern(S)(dchar c, S[] patterns) @safe pure @nogc if (isSomeString!S) * Count characters in s that match pattern. */ -size_t countchars(S, S1)(S s, in S1 pattern) @safe pure @nogc if (isSomeString!S && isSomeString!S1) +size_t countchars(S, S1)(S s, in S1 pattern) @safe pure @nogc +if (isSomeString!S && isSomeString!S1) { size_t count; foreach (dchar c; s) @@ -5359,7 +5363,8 @@ size_t countchars(S, S1)(S s, in S1 pattern) @safe pure @nogc if (isSomeString!S * Return string that is s with all characters removed that match pattern. */ -S removechars(S)(S s, in S pattern) @safe pure if (isSomeString!S) +S removechars(S)(S s, in S pattern) @safe pure +if (isSomeString!S) { import std.utf : encode; @@ -5536,7 +5541,8 @@ S1 munch(S1, S2)(ref S1 s, S2 pattern) @safe pure @nogc * repeated with the one to its immediate left. */ -S succ(S)(S s) @safe pure if (isSomeString!S) +S succ(S)(S s) @safe pure +if (isSomeString!S) { import std.ascii : isAlphaNum; @@ -5836,7 +5842,8 @@ C1[] tr(C1, C2, C3, C4 = immutable char) * Returns: * $(D bool) */ -bool isNumeric(S)(S s, bool bAllowSep = false) if (isSomeString!S || +bool isNumeric(S)(S s, bool bAllowSep = false) +if (isSomeString!S || (isRandomAccessRange!S && hasSlicing!S && isSomeChar!(ElementType!S) && @@ -6168,8 +6175,8 @@ bool isNumeric(S)(S s, bool bAllowSep = false) if (isSomeString!S || * but this one is the standard one. */ char[4] soundexer(Range)(Range str) - if (isInputRange!Range && isSomeChar!(ElementEncodingType!Range) && - !isConvertibleToString!Range) +if (isInputRange!Range && isSomeChar!(ElementEncodingType!Range) && + !isConvertibleToString!Range) { alias C = Unqual!(ElementEncodingType!Range); @@ -6224,7 +6231,7 @@ char[4] soundexer(Range)(Range str) } char[4] soundexer(Range)(auto ref Range str) - if (isConvertibleToString!Range) +if (isConvertibleToString!Range) { return soundexer!(StringTypeOf!Range)(str); } @@ -6456,9 +6463,9 @@ string[string] abbrev(string[] values) @safe pure */ size_t column(Range)(Range str, in size_t tabsize = 8) - if ((isInputRange!Range && isSomeChar!(Unqual!(ElementEncodingType!Range)) || - isNarrowString!Range) && - !isConvertibleToString!Range) +if ((isInputRange!Range && isSomeChar!(Unqual!(ElementEncodingType!Range)) || + isNarrowString!Range) && + !isConvertibleToString!Range) { static if (is(Unqual!(ElementEncodingType!Range) == char)) { @@ -6536,7 +6543,7 @@ size_t column(Range)(Range str, in size_t tabsize = 8) } size_t column(Range)(auto ref Range str, in size_t tabsize = 8) - if (isConvertibleToString!Range) +if (isConvertibleToString!Range) { return column!(StringTypeOf!Range)(str, tabsize); } @@ -6582,7 +6589,8 @@ size_t column(Range)(auto ref Range str, in size_t tabsize = 8) */ S wrap(S)(S s, in size_t columns = 80, S firstindent = null, - S indent = null, in size_t tabsize = 8) if (isSomeString!S) +S indent = null, in size_t tabsize = 8) +if (isSomeString!S) { import std.uni : isWhite; typeof(s.dup) result; @@ -6699,7 +6707,8 @@ S wrap(S)(S s, in size_t columns = 80, S firstindent = null, * StringException if indentation is done with different sequences * of whitespace characters. */ -S outdent(S)(S str) @safe pure if (isSomeString!S) +S outdent(S)(S str) @safe pure +if (isSomeString!S) { return str.splitLines(Yes.keepTerminator).outdent().join(); } @@ -6741,7 +6750,8 @@ void main() { * StringException if indentation is done with different sequences * of whitespace characters. */ -S[] outdent(S)(S[] lines) @safe pure if (isSomeString!S) +S[] outdent(S)(S[] lines) @safe pure +if (isSomeString!S) { import std.algorithm.searching : startsWith; @@ -6917,7 +6927,7 @@ Returns: See_Also: $(LREF representation) */ auto assumeUTF(T)(T[] arr) pure - if (staticIndexOf!(Unqual!T, ubyte, ushort, uint) != -1) +if (staticIndexOf!(Unqual!T, ubyte, ushort, uint) != -1) { import std.traits : ModifyTypePreservingTQ; import std.utf : validate; diff --git a/std/uni.d b/std/uni.d index 5c7754408..473f7551f 100644 --- a/std/uni.d +++ b/std/uni.d @@ -745,21 +745,21 @@ public enum dchar nelSep = '\u0085'; /// Constant $(CODEPOINT) (0x0085) - next enum lastDchar = 0x10FFFF; auto force(T, F)(F from) - if (isIntegral!T && !is(T == F)) +if (isIntegral!T && !is(T == F)) { assert(from <= T.max && from >= T.min); return cast(T)from; } auto force(T, F)(F from) - if (isBitPacked!T && !is(T == F)) +if (isBitPacked!T && !is(T == F)) { assert(from <= 2^^bitSizeOf!T-1); return T(cast(TypeOfBitPacked!T)from); } auto force(T, F)(F from) - if (is(T == F)) +if (is(T == F)) { return from; } @@ -1084,8 +1084,8 @@ template isBitPackableType(T) //============================================================================ template PackedArrayView(T) - if ((is(T dummy == BitPacked!(U, sz), U, size_t sz) - && isBitPackableType!U) || isBitPackableType!T) +if ((is(T dummy == BitPacked!(U, sz), U, size_t sz) + && isBitPackableType!U) || isBitPackableType!T) { import std.math : nextPow2; private enum bits = bitSizeOf!T; @@ -1094,8 +1094,8 @@ template PackedArrayView(T) //unsafe and fast access to a chunk of RAM as if it contains packed values template PackedPtr(T) - if ((is(T dummy == BitPacked!(U, sz), U, size_t sz) - && isBitPackableType!U) || isBitPackableType!T) +if ((is(T dummy == BitPacked!(U, sz), U, size_t sz) + && isBitPackableType!U) || isBitPackableType!T) { import std.math : nextPow2; private enum bits = bitSizeOf!T; @@ -1439,7 +1439,7 @@ private: static assert(isRandomAccessRange!(SliceOverIndexed!(int[]))); SliceOverIndexed!(const(T)) sliceOverIndexed(T)(size_t a, size_t b, const(T)* x) - if (is(Unqual!T == T)) +if (is(Unqual!T == T)) { return SliceOverIndexed!(const(T))(a, b, x); } @@ -1447,7 +1447,7 @@ SliceOverIndexed!(const(T)) sliceOverIndexed(T)(size_t a, size_t b, const(T)* x) // BUG? inout is out of reach //...SliceOverIndexed.arr only parameters or stack based variables can be inout SliceOverIndexed!T sliceOverIndexed(T)(size_t a, size_t b, T* x) - if (is(Unqual!T == T)) +if (is(Unqual!T == T)) { return SliceOverIndexed!T(a, b, x); } @@ -1540,7 +1540,7 @@ bool isPow2OrZero(size_t sz) @safe pure nothrow @nogc } size_t uniformLowerBound(alias pred, Range, T)(Range range, T needle) - if (is(T : ElementType!Range)) +if (is(T : ElementType!Range)) { assert(isPow2OrZero(range.length)); size_t idx = 0, m = range.length/2; @@ -1556,7 +1556,7 @@ size_t uniformLowerBound(alias pred, Range, T)(Range range, T needle) } size_t switchUniformLowerBound(alias pred, Range, T)(Range range, T needle) - if (is(T : ElementType!Range)) +if (is(T : ElementType!Range)) { assert(isPow2OrZero(range.length)); size_t idx = 0, m = range.length/2; @@ -3719,7 +3719,7 @@ template mapTrieIndex(Prefix...) See $(LREF buildTrie) for generic helpers built on top of it. */ @trusted private struct TrieBuilder(Value, Key, Args...) - if (isBitPackableType!Value && isValidArgsForTrie!(Key, Args)) +if (isBitPackableType!Value && isValidArgsForTrie!(Key, Args)) { import std.exception : enforce; @@ -4019,9 +4019,9 @@ public: */ @trusted private struct Trie(Value, Key, Args...) - if (isValidPrefixForTrie!(Key, Args) - || (isValidPrefixForTrie!(Key, Args[1..$]) - && is(typeof(Args[0]) : size_t))) +if (isValidPrefixForTrie!(Key, Args) + || (isValidPrefixForTrie!(Key, Args[1..$]) + && is(typeof(Args[0]) : size_t))) { import std.range.primitives : isOutputRange; static if (is(typeof(Args[0]) : size_t)) @@ -4188,7 +4188,7 @@ template isValidArgsForTrie(Key, Args...) --- */ public template codepointSetTrie(sizes...) - if (sumOfIntegerTuple!sizes == 21) +if (sumOfIntegerTuple!sizes == 21) { auto codepointSetTrie(Set)(Set set) if (isCodepointSet!Set) @@ -4202,7 +4202,7 @@ public template codepointSetTrie(sizes...) /// Type of Trie generated by codepointSetTrie function. public template CodepointSetTrie(sizes...) - if (sumOfIntegerTuple!sizes == 21) +if (sumOfIntegerTuple!sizes == 21) { alias Prefix = GetBitSlicing!(21, sizes); alias CodepointSetTrie = typeof(TrieBuilder!(bool, dchar, lastDchar+1, Prefix)(false).build()); @@ -4219,7 +4219,7 @@ public template CodepointSetTrie(sizes...) only to bool mapping $(D Trie)s. */ public template codepointTrie(T, sizes...) - if (sumOfIntegerTuple!sizes == 21) +if (sumOfIntegerTuple!sizes == 21) { alias Prefix = GetBitSlicing!(21, sizes); @@ -4304,7 +4304,7 @@ public template codepointTrie(T, sizes...) /// Type of Trie as generated by codepointTrie function. public template CodepointTrie(T, sizes...) - if (sumOfIntegerTuple!sizes == 21) +if (sumOfIntegerTuple!sizes == 21) { alias Prefix = GetBitSlicing!(21, sizes); alias CodepointTrie = typeof(TrieBuilder!(T, dchar, lastDchar+1, Prefix)(T.init).build()); @@ -4333,7 +4333,7 @@ package template cmpK0(alias Pred) and the maximum Key is deduced from predicates. */ private template buildTrie(Value, Key, Args...) - if (isValidArgsForTrie!(Key, Args)) +if (isValidArgsForTrie!(Key, Args)) { static if (is(typeof(Args[0]) : Key)) // prefix starts with upper bound on Key { @@ -5164,7 +5164,7 @@ private auto utf16Matcher(Set)(Set set) @trusted See $(LREF MatcherConcept) for API outline. */ public auto utfMatcher(Char, Set)(Set set) @trusted - if (isCodepointSet!Set) +if (isCodepointSet!Set) { static if (is(Char : char)) return utf8Matcher(set); @@ -5180,7 +5180,7 @@ public auto utfMatcher(Char, Set)(Set set) @trusted //a range of code units, packed with index to speed up forward iteration package auto decoder(C)(C[] s, size_t offset=0) @safe pure nothrow @nogc - if (is(C : wchar) || is(C : char)) +if (is(C : wchar) || is(C : char)) { static struct Decoder { @@ -5359,7 +5359,7 @@ package auto decoder(C)(C[] s, size_t offset=0) @safe pure nothrow @nogc +/ public auto toTrie(size_t level, Set)(Set set) - if (isCodepointSet!Set) +if (isCodepointSet!Set) { static if (level == 1) return codepointSetTrie!(21)(set); @@ -5385,7 +5385,7 @@ public auto toTrie(size_t level, Set)(Set set) See the $(S_LINK Synopsis, Synopsis) section for example. */ public auto toDelegate(Set)(Set set) - if (isCodepointSet!Set) +if (isCodepointSet!Set) { // 3 is very small and is almost as fast as 2-level (due to CPU caches?) auto t = toTrie!3(set); @@ -5407,7 +5407,7 @@ public auto toDelegate(Set)(Set set) operator to perform the conversion.) */ struct BitPacked(T, size_t sz) - if (isIntegral!T || is(T:dchar)) +if (isIntegral!T || is(T:dchar)) { enum bitSize = sz; T _value; @@ -5420,7 +5420,7 @@ struct BitPacked(T, size_t sz) or a return type of a given functor. */ template bitSizeOf(Args...) - if (Args.length == 1) +if (Args.length == 1) { import std.traits : ReturnType; alias T = Args[0]; @@ -5624,7 +5624,7 @@ template Sequence(size_t start, size_t end) } template useItemAt(size_t idx, T) - if (isIntegral!T || is(T: dchar)) +if (isIntegral!T || is(T: dchar)) { size_t impl(in T[] arr){ return arr[idx]; } alias useItemAt = assumeSize!(impl, 8*T.sizeof); @@ -5668,7 +5668,7 @@ template idxTypes(Key, size_t fullBits, Prefix...) //============================================================================ @safe pure int comparePropertyName(Char1, Char2)(const(Char1)[] a, const(Char2)[] b) - if (is(Char1 : dchar) && is(Char2 : dchar)) +if (is(Char1 : dchar) && is(Char2 : dchar)) { import std.algorithm.comparison : cmp; import std.algorithm.iteration : map, filter; @@ -5685,7 +5685,7 @@ template idxTypes(Key, size_t fullBits, Prefix...) } bool propertyNameLess(Char1, Char2)(const(Char1)[] a, const(Char2)[] b) @safe pure - if (is(Char1 : dchar) && is(Char2 : dchar)) +if (is(Char1 : dchar) && is(Char2 : dchar)) { return comparePropertyName(a, b) < 0; } @@ -5730,7 +5730,7 @@ bool propertyNameLess(Char1, Char2)(const(Char1)[] a, const(Char2)[] b) @safe pu package ubyte[] compressIntervals(Range)(Range intervals) - if (isInputRange!Range && isIntegralPair!(ElementType!Range)) +if (isInputRange!Range && isIntegralPair!(ElementType!Range)) { ubyte[] storage; uint base = 0; @@ -6347,7 +6347,7 @@ public: // Public API continues length of grapheme cluster +/ size_t graphemeStride(C)(in C[] input, size_t index) - if (is(C : dchar)) +if (is(C : dchar)) { auto src = input[index..$]; auto n = src.length; @@ -6377,7 +6377,7 @@ size_t graphemeStride(C)(in C[] input, size_t index) must be an L-value. +/ Grapheme decodeGrapheme(Input)(ref Input inp) - if (isInputRange!Input && is(Unqual!(ElementType!Input) == dchar)) +if (isInputRange!Input && is(Unqual!(ElementType!Input) == dchar)) { return genericDecodeGrapheme!true(inp); } @@ -6410,7 +6410,7 @@ Grapheme decodeGrapheme(Input)(ref Input inp) $(LREF byCodePoint) +/ auto byGrapheme(Range)(Range range) - if (isInputRange!Range && is(Unqual!(ElementType!Range) == dchar)) +if (isInputRange!Range && is(Unqual!(ElementType!Range) == dchar)) { // TODO: Bidirectional access static struct Result @@ -6513,7 +6513,7 @@ private static struct InputRangeString $(P Acts as the identity function when given a range of code points.) +/ auto byCodePoint(Range)(Range range) - if (isInputRange!Range && is(Unqual!(ElementType!Range) == Grapheme)) +if (isInputRange!Range && is(Unqual!(ElementType!Range) == Grapheme)) { // TODO: Propagate bidirectional access static struct Result @@ -6556,7 +6556,7 @@ auto byCodePoint(Range)(Range range) /// Ditto Range byCodePoint(Range)(Range range) - if (isInputRange!Range && is(Unqual!(ElementType!Range) == dchar)) +if (isInputRange!Range && is(Unqual!(ElementType!Range) == dchar)) { return range; } @@ -6980,7 +6980,7 @@ static assert(Grapheme.sizeof == size_t.sizeof*4); $(REF cmp, std,algorithm,comparison) +/ int sicmp(S1, S2)(S1 r1, S2 r2) - if (isInputRange!S1 && isSomeChar!(ElementEncodingType!S1) +if (isInputRange!S1 && isSomeChar!(ElementEncodingType!S1) && isInputRange!S2 && isSomeChar!(ElementEncodingType!S2)) { import std.internal.unicode_tables : sTable = simpleCaseTable; // generated file @@ -7112,7 +7112,7 @@ private int fullCasedCmp(Range)(dchar lhs, dchar rhs, ref Range rtail) $(REF cmp, std,algorithm,comparison) +/ int icmp(S1, S2)(S1 r1, S2 r2) - if (isForwardRange!S1 && isSomeChar!(ElementEncodingType!S1) +if (isForwardRange!S1 && isSomeChar!(ElementEncodingType!S1) && isForwardRange!S2 && isSomeChar!(ElementEncodingType!S2)) { import std.utf : byDchar; @@ -8102,7 +8102,7 @@ private alias LowerTriple = AliasSeq!(toLowerIndex, MAX_SIMPLE_LOWER, toLowerTab // generic toUpper/toLower on whole string, creates new or returns as is private S toCase(alias indexFn, uint maxIdx, alias tableFn, alias asciiConvert, S)(S s) @trusted pure - if (isSomeString!S) +if (isSomeString!S) { import std.array : appender; import std.ascii : isASCII; @@ -8161,9 +8161,9 @@ private S toCase(alias indexFn, uint maxIdx, alias tableFn, alias asciiConvert, // generic toUpper/toLower on whole range, returns range private auto toCaser(alias indexFn, uint maxIdx, alias tableFn, alias asciiConvert, Range)(Range str) // Accept range of dchar's - if (isInputRange!Range && - isSomeChar!(ElementEncodingType!Range) && - ElementEncodingType!Range.sizeof == dchar.sizeof) +if (isInputRange!Range && + isSomeChar!(ElementEncodingType!Range) && + ElementEncodingType!Range.sizeof == dchar.sizeof) { static struct ToCaserImpl { @@ -8261,8 +8261,8 @@ private auto toCaser(alias indexFn, uint maxIdx, alias tableFn, alias asciiConve */ auto asLowerCase(Range)(Range str) - if (isInputRange!Range && isSomeChar!(ElementEncodingType!Range) && - !isConvertibleToString!Range) +if (isInputRange!Range && isSomeChar!(ElementEncodingType!Range) && + !isConvertibleToString!Range) { static if (ElementEncodingType!Range.sizeof < dchar.sizeof) { @@ -8280,8 +8280,8 @@ auto asLowerCase(Range)(Range str) /// ditto auto asUpperCase(Range)(Range str) - if (isInputRange!Range && isSomeChar!(ElementEncodingType!Range) && - !isConvertibleToString!Range) +if (isInputRange!Range && isSomeChar!(ElementEncodingType!Range) && + !isConvertibleToString!Range) { static if (ElementEncodingType!Range.sizeof < dchar.sizeof) { @@ -8307,7 +8307,7 @@ auto asUpperCase(Range)(Range str) // explicitly undocumented auto asLowerCase(Range)(auto ref Range str) - if (isConvertibleToString!Range) +if (isConvertibleToString!Range) { import std.traits : StringTypeOf; return asLowerCase!(StringTypeOf!Range)(str); @@ -8315,7 +8315,7 @@ auto asLowerCase(Range)(auto ref Range str) // explicitly undocumented auto asUpperCase(Range)(auto ref Range str) - if (isConvertibleToString!Range) +if (isConvertibleToString!Range) { import std.traits : StringTypeOf; return asUpperCase!(StringTypeOf!Range)(str); @@ -8371,9 +8371,9 @@ auto asUpperCase(Range)(auto ref Range str) private auto toCapitalizer(alias indexFnUpper, uint maxIdxUpper, alias tableFnUpper, Range)(Range str) // Accept range of dchar's - if (isInputRange!Range && - isSomeChar!(ElementEncodingType!Range) && - ElementEncodingType!Range.sizeof == dchar.sizeof) +if (isInputRange!Range && + isSomeChar!(ElementEncodingType!Range) && + ElementEncodingType!Range.sizeof == dchar.sizeof) { static struct ToCapitalizerImpl { @@ -8478,8 +8478,8 @@ private auto toCapitalizer(alias indexFnUpper, uint maxIdxUpper, alias tableFnUp */ auto asCapitalized(Range)(Range str) - if (isInputRange!Range && isSomeChar!(ElementEncodingType!Range) && - !isConvertibleToString!Range) +if (isInputRange!Range && isSomeChar!(ElementEncodingType!Range) && + !isConvertibleToString!Range) { static if (ElementEncodingType!Range.sizeof < dchar.sizeof) { @@ -8503,7 +8503,7 @@ auto asCapitalized(Range)(Range str) } auto asCapitalized(Range)(auto ref Range str) - if (isConvertibleToString!Range) +if (isConvertibleToString!Range) { import std.traits : StringTypeOf; return asCapitalized!(StringTypeOf!Range)(str); @@ -8643,7 +8643,7 @@ private size_t encodeTo(scope dchar[] buf, size_t idx, dchar c) @trusted pure no } private void toCaseInPlace(alias indexFn, uint maxIdx, alias tableFn, C)(ref C[] s) @trusted pure - if (is(C == char) || is(C == wchar) || is(C == dchar)) +if (is(C == char) || is(C == wchar) || is(C == dchar)) { import std.utf : decode, codeLength; size_t curIdx = 0; @@ -8820,7 +8820,7 @@ private template toCaseInPlaceAlloc(alias indexFn, uint maxIdx, alias tableFn) If $(D s) does not have any uppercase characters, then $(D s) is unaltered. +/ void toLowerInPlace(C)(ref C[] s) @trusted pure - if (is(C == char) || is(C == wchar) || is(C == dchar)) +if (is(C == char) || is(C == wchar) || is(C == dchar)) { toCaseInPlace!(LowerTriple)(s); } @@ -8842,7 +8842,7 @@ void toLowerInPlace(C)(ref C[] s) @trusted pure If $(D s) does not have any lowercase characters, then $(D s) is unaltered. +/ void toUpperInPlace(C)(ref C[] s) @trusted pure - if (is(C == char) || is(C == wchar) || is(C == dchar)) +if (is(C == char) || is(C == wchar) || is(C == dchar)) { toCaseInPlace!(UpperTriple)(s); } @@ -8890,7 +8890,7 @@ dchar toLower(dchar c) If none of $(D s) characters were affected, then $(D s) itself is returned. +/ S toLower(S)(S s) @trusted pure - if (isSomeString!S) +if (isSomeString!S) { static import std.ascii; return toCase!(LowerTriple, std.ascii.toLower)(s); @@ -9072,7 +9072,7 @@ dchar toUpper(dchar c) If none of $(D s) characters were affected, then $(D s) itself is returned. +/ S toUpper(S)(S s) @trusted pure - if (isSomeString!S) +if (isSomeString!S) { static import std.ascii; return toCase!(UpperTriple, std.ascii.toUpper)(s); diff --git a/std/uri.d b/std/uri.d index 9d6bac77d..9a077ec86 100644 --- a/std/uri.d +++ b/std/uri.d @@ -193,7 +193,8 @@ private uint ascii2hex(dchar c) @nogc @safe pure nothrow c - 'a' + 10; } -private dstring URI_Decode(Char)(in Char[] uri, uint reservedSet) if (isSomeChar!Char) +private dstring URI_Decode(Char)(in Char[] uri, uint reservedSet) +if (isSomeChar!Char) { import core.exception : OutOfMemoryError; import core.stdc.stdlib : alloca; @@ -312,7 +313,8 @@ private dstring URI_Decode(Char)(in Char[] uri, uint reservedSet) if (isSomeChar * Escape sequences that resolve to the '#' character are not replaced. */ -string decode(Char)(in Char[] encodedURI) if (isSomeChar!Char) +string decode(Char)(in Char[] encodedURI) +if (isSomeChar!Char) { import std.utf : toUTF8; auto s = URI_Decode(encodedURI, URI_Reserved | URI_Hash); @@ -324,7 +326,8 @@ string decode(Char)(in Char[] encodedURI) if (isSomeChar!Char) * escape sequences are decoded. */ -string decodeComponent(Char)(in Char[] encodedURIComponent) if (isSomeChar!Char) +string decodeComponent(Char)(in Char[] encodedURIComponent) +if (isSomeChar!Char) { import std.utf : toUTF8; auto s = URI_Decode(encodedURIComponent, 0); @@ -336,7 +339,8 @@ string decodeComponent(Char)(in Char[] encodedURIComponent) if (isSomeChar!Char) * not a valid URI character is escaped. The '#' character is not escaped. */ -string encode(Char)(in Char[] uri) if (isSomeChar!Char) +string encode(Char)(in Char[] uri) +if (isSomeChar!Char) { import std.utf : toUTF32; auto s = toUTF32(uri); @@ -348,7 +352,8 @@ string encode(Char)(in Char[] uri) if (isSomeChar!Char) * Any character not a letter, digit, or one of -_.!~*'() is escaped. */ -string encodeComponent(Char)(in Char[] uriComponent) if (isSomeChar!Char) +string encodeComponent(Char)(in Char[] uriComponent) +if (isSomeChar!Char) { import std.utf : toUTF32; auto s = toUTF32(uriComponent); @@ -402,7 +407,8 @@ package string urlEncode(in string[string] values) * len it does, and s[0..len] is the slice of s[] that is that URL */ -ptrdiff_t uriLength(Char)(in Char[] s) if (isSomeChar!Char) +ptrdiff_t uriLength(Char)(in Char[] s) +if (isSomeChar!Char) { /* Must start with one of: * http:// @@ -472,7 +478,8 @@ ptrdiff_t uriLength(Char)(in Char[] s) if (isSomeChar!Char) * References: * RFC2822 */ -ptrdiff_t emailLength(Char)(in Char[] s) if (isSomeChar!Char) +ptrdiff_t emailLength(Char)(in Char[] s) +if (isSomeChar!Char) { import std.ascii : isAlpha, isAlphaNum; diff --git a/std/utf.d b/std/utf.d index c63d5d5d8..6559399ce 100644 --- a/std/utf.d +++ b/std/utf.d @@ -112,7 +112,7 @@ class UTFException : Exception */ package auto invalidUTFstrings(Char)() @safe pure @nogc nothrow - if (isSomeChar!Char) +if (isSomeChar!Char) { static if (is(Char == char)) { @@ -262,8 +262,8 @@ pure nothrow @safe @nogc unittest $(D index + stride(str, index) <= str.length). +/ uint stride(S)(auto ref S str, size_t index) - if (is(S : const char[]) || - (isRandomAccessRange!S && is(Unqual!(ElementType!S) == char))) +if (is(S : const char[]) || + (isRandomAccessRange!S && is(Unqual!(ElementType!S) == char))) { static if (is(typeof(str.length) : ulong)) assert(index < str.length, "Past the end of the UTF-8 sequence"); @@ -277,8 +277,8 @@ uint stride(S)(auto ref S str, size_t index) /// Ditto uint stride(S)(auto ref S str) - if (is(S : const char[]) || - (isInputRange!S && is(Unqual!(ElementType!S) == char))) +if (is(S : const char[]) || + (isInputRange!S && is(Unqual!(ElementType!S) == char))) { static if (is(S : const char[])) immutable c = str[0]; @@ -385,8 +385,8 @@ body /// Ditto uint stride(S)(auto ref S str, size_t index) - if (is(S : const wchar[]) || - (isRandomAccessRange!S && is(Unqual!(ElementType!S) == wchar))) +if (is(S : const wchar[]) || + (isRandomAccessRange!S && is(Unqual!(ElementType!S) == wchar))) { static if (is(typeof(str.length) : ulong)) assert(index < str.length, "Past the end of the UTF-16 sequence"); @@ -396,14 +396,14 @@ uint stride(S)(auto ref S str, size_t index) /// Ditto uint stride(S)(auto ref S str) @safe pure - if (is(S : const wchar[])) +if (is(S : const wchar[])) { return stride(str, 0); } /// Ditto uint stride(S)(auto ref S str) - if (isInputRange!S && is(Unqual!(ElementType!S) == wchar)) +if (isInputRange!S && is(Unqual!(ElementType!S) == wchar)) { assert(!str.empty, "UTF-16 sequence is empty"); immutable uint u = str.front; @@ -479,8 +479,8 @@ uint stride(S)(auto ref S str) /// Ditto uint stride(S)(auto ref S str, size_t index = 0) - if (is(S : const dchar[]) || - (isInputRange!S && is(Unqual!(ElementEncodingType!S) == dchar))) +if (is(S : const dchar[]) || + (isInputRange!S && is(Unqual!(ElementEncodingType!S) == dchar))) { static if (is(typeof(str.length) : ulong)) assert(index < str.length, "Past the end of the UTF-32 sequence"); @@ -581,8 +581,8 @@ uint stride(S)(auto ref S str, size_t index = 0) guarantee that $(D strideBack(str, index) <= index). +/ uint strideBack(S)(auto ref S str, size_t index) - if (is(S : const char[]) || - (isRandomAccessRange!S && is(Unqual!(ElementType!S) == char))) +if (is(S : const char[]) || + (isRandomAccessRange!S && is(Unqual!(ElementType!S) == char))) { static if (is(typeof(str.length) : ulong)) assert(index <= str.length, "Past the end of the UTF-8 sequence"); @@ -612,15 +612,15 @@ uint strideBack(S)(auto ref S str, size_t index) /// Ditto uint strideBack(S)(auto ref S str) - if (is(S : const char[]) || - (isRandomAccessRange!S && hasLength!S && is(Unqual!(ElementType!S) == char))) +if (is(S : const char[]) || + (isRandomAccessRange!S && hasLength!S && is(Unqual!(ElementType!S) == char))) { return strideBack(str, str.length); } /// Ditto uint strideBack(S)(auto ref S str) - if (isBidirectionalRange!S && is(Unqual!(ElementType!S) == char) && !isRandomAccessRange!S) +if (isBidirectionalRange!S && is(Unqual!(ElementType!S) == char) && !isRandomAccessRange!S) { assert(!str.empty, "Past the end of the UTF-8 sequence"); auto temp = str.save; @@ -706,8 +706,8 @@ uint strideBack(S)(auto ref S str) //the value of a single wchar /// Ditto uint strideBack(S)(auto ref S str, size_t index) - if (is(S : const wchar[]) || - (isRandomAccessRange!S && is(Unqual!(ElementType!S) == wchar))) +if (is(S : const wchar[]) || + (isRandomAccessRange!S && is(Unqual!(ElementType!S) == wchar))) { static if (is(typeof(str.length) : ulong)) assert(index <= str.length, "Past the end of the UTF-16 sequence"); @@ -719,8 +719,8 @@ uint strideBack(S)(auto ref S str, size_t index) /// Ditto uint strideBack(S)(auto ref S str) - if (is(S : const wchar[]) || - (isBidirectionalRange!S && is(Unqual!(ElementType!S) == wchar))) +if (is(S : const wchar[]) || + (isBidirectionalRange!S && is(Unqual!(ElementType!S) == wchar))) { assert(!str.empty, "UTF-16 sequence is empty"); @@ -801,7 +801,7 @@ uint strideBack(S)(auto ref S str) /// Ditto uint strideBack(S)(auto ref S str, size_t index) - if (isRandomAccessRange!S && is(Unqual!(ElementEncodingType!S) == dchar)) +if (isRandomAccessRange!S && is(Unqual!(ElementEncodingType!S) == dchar)) { static if (is(typeof(str.length) : ulong)) assert(index <= str.length, "Past the end of the UTF-32 sequence"); @@ -811,7 +811,7 @@ uint strideBack(S)(auto ref S str, size_t index) /// Ditto uint strideBack(S)(auto ref S str) - if (isBidirectionalRange!S && is(Unqual!(ElementEncodingType!S) == dchar)) +if (isBidirectionalRange!S && is(Unqual!(ElementEncodingType!S) == dchar)) { assert(!str.empty, "Empty UTF-32 sequence"); return 1; @@ -893,7 +893,7 @@ uint strideBack(S)(auto ref S str) the string that that code point is. +/ size_t toUCSindex(C)(const(C)[] str, size_t index) @safe pure - if (isSomeChar!C) +if (isSomeChar!C) { static if (is(Unqual!C == dchar)) return index; @@ -940,7 +940,7 @@ size_t toUCSindex(C)(const(C)[] str, size_t index) @safe pure the array index of the code unit is returned. +/ size_t toUTFindex(C)(const(C)[] str, size_t n) @safe pure - if (isSomeChar!C) +if (isSomeChar!C) { static if (is(Unqual!C == dchar)) { @@ -1002,8 +1002,8 @@ alias UseReplacementDchar = Flag!"useReplacementDchar"; sequence and useReplacementDchar is $(D No.useReplacementDchar) +/ dchar decode(UseReplacementDchar useReplacementDchar = No.useReplacementDchar, S)(auto ref S str, ref size_t index) - if (!isSomeString!S && - isRandomAccessRange!S && hasSlicing!S && hasLength!S && isSomeChar!(ElementType!S)) +if (!isSomeString!S && + isRandomAccessRange!S && hasSlicing!S && hasLength!S && isSomeChar!(ElementType!S)) in { assert(index < str.length, "Attempted to decode past the end of a string"); @@ -1021,7 +1021,8 @@ body } dchar decode(UseReplacementDchar useReplacementDchar = No.useReplacementDchar, S)( - auto ref S str, ref size_t index) @trusted pure if (isSomeString!S) +auto ref S str, ref size_t index) @trusted pure +if (isSomeString!S) in { assert(index < str.length, "Attempted to decode past the end of a string"); @@ -1062,7 +1063,8 @@ body before the code point was determined to be invalid. +/ dchar decodeFront(UseReplacementDchar useReplacementDchar = No.useReplacementDchar, S)( - ref S str, out size_t numCodeUnits) if (!isSomeString!S && isInputRange!S && isSomeChar!(ElementType!S)) +ref S str, out size_t numCodeUnits) +if (!isSomeString!S && isInputRange!S && isSomeChar!(ElementType!S)) in { assert(!str.empty); @@ -1098,7 +1100,8 @@ body } dchar decodeFront(UseReplacementDchar useReplacementDchar = No.useReplacementDchar, S)( - ref S str, out size_t numCodeUnits) @trusted pure if (isSomeString!S) +ref S str, out size_t numCodeUnits) @trusted pure +if (isSomeString!S) in { assert(!str.empty); @@ -1126,7 +1129,7 @@ body /++ Ditto +/ dchar decodeFront(UseReplacementDchar useReplacementDchar = No.useReplacementDchar, S)(ref S str) - if (isInputRange!S && isSomeChar!(ElementType!S)) +if (isInputRange!S && isSomeChar!(ElementType!S)) { size_t numCodeUnits; return decodeFront!useReplacementDchar(str, numCodeUnits); @@ -1155,7 +1158,7 @@ dchar decodeFront(UseReplacementDchar useReplacementDchar = No.useReplacementDch +/ dchar decodeBack(UseReplacementDchar useReplacementDchar = No.useReplacementDchar, S)( ref S str, out size_t numCodeUnits) - if (isSomeString!S) +if (isSomeString!S) in { assert(!str.empty); @@ -1187,8 +1190,8 @@ body /++ Ditto +/ dchar decodeBack(UseReplacementDchar useReplacementDchar = No.useReplacementDchar, S)( ref S str, out size_t numCodeUnits) - if (!isSomeString!S && isSomeChar!(ElementType!S) && isBidirectionalRange!S - && ((isRandomAccessRange!S && hasLength!S) || !isRandomAccessRange!S)) +if (!isSomeString!S && isSomeChar!(ElementType!S) && isBidirectionalRange!S + && ((isRandomAccessRange!S && hasLength!S) || !isRandomAccessRange!S)) in { assert(!str.empty); @@ -1237,9 +1240,9 @@ body /++ Ditto +/ dchar decodeBack(UseReplacementDchar useReplacementDchar = No.useReplacementDchar, S)(ref S str) - if (isSomeString!S - || (isRandomAccessRange!S && hasLength!S && isSomeChar!(ElementType!S)) - || (!isRandomAccessRange!S && isBidirectionalRange!S && isSomeChar!(ElementType!S))) +if (isSomeString!S + || (isRandomAccessRange!S && hasLength!S && isSomeChar!(ElementType!S)) + || (!isRandomAccessRange!S && isBidirectionalRange!S && isSomeChar!(ElementType!S))) in { assert(!str.empty); @@ -1256,7 +1259,7 @@ body // Gives the maximum value that a code unit for the given range type can hold. package template codeUnitLimit(S) - if (isSomeChar!(ElementEncodingType!S)) +if (isSomeChar!(ElementEncodingType!S)) { static if (is(Unqual!(ElementEncodingType!S) == char)) enum char codeUnitLimit = 0x80; @@ -1284,7 +1287,8 @@ package template codeUnitLimit(S) * decoded character */ private dchar decodeImpl(bool canIndex, UseReplacementDchar useReplacementDchar = No.useReplacementDchar, S)( - auto ref S str, ref size_t index) if ( + auto ref S str, ref size_t index) +if ( is(S : const char[]) || (isInputRange!S && is(Unqual!(ElementEncodingType!S) == char))) { /* The following encodings are valid, except for the 5 and 6 byte @@ -1515,7 +1519,7 @@ unittest private dchar decodeImpl(bool canIndex, UseReplacementDchar useReplacementDchar = No.useReplacementDchar, S) (auto ref S str, ref size_t index) - if (is(S : const wchar[]) || (isInputRange!S && is(Unqual!(ElementEncodingType!S) == wchar))) +if (is(S : const wchar[]) || (isInputRange!S && is(Unqual!(ElementEncodingType!S) == wchar))) { static if (is(S : const wchar[])) auto pstr = str.ptr + index; @@ -1632,7 +1636,7 @@ unittest private dchar decodeImpl(bool canIndex, UseReplacementDchar useReplacementDchar = No.useReplacementDchar, S)( auto ref S str, ref size_t index) - if (is(S : const dchar[]) || (isInputRange!S && is(Unqual!(ElementEncodingType!S) == dchar))) +if (is(S : const dchar[]) || (isInputRange!S && is(Unqual!(ElementEncodingType!S) == dchar))) { static if (is(S : const dchar[])) auto pstr = str.ptr; @@ -2480,7 +2484,7 @@ void encode(UseReplacementDchar useReplacementDchar = No.useReplacementDchar)( $(D c) when $(D C) is the character type used to encode it. +/ ubyte codeLength(C)(dchar c) @safe pure nothrow @nogc - if (isSomeChar!C) +if (isSomeChar!C) { static if (C.sizeof == 1) { @@ -2527,7 +2531,7 @@ ubyte codeLength(C)(dchar c) @safe pure nothrow @nogc The number of code units in `input` when encoded to `C` +/ size_t codeLength(C, InputRange)(InputRange input) - if (isInputRange!InputRange && !isInfinite!InputRange && is(ElementType!InputRange : dchar)) +if (isInputRange!InputRange && !isInfinite!InputRange && is(ElementType!InputRange : dchar)) { alias EncType = Unqual!(ElementEncodingType!InputRange); static if (isSomeString!InputRange && is(EncType == C) && is(typeof(input.length))) @@ -2641,7 +2645,7 @@ if (isSomeChar!C) $(D UTFException) if $(D str) is not well-formed. +/ void validate(S)(in S str) @safe pure - if (isSomeString!S) +if (isSomeString!S) { immutable len = str.length; for (size_t i = 0; i < len; ) @@ -2713,7 +2717,8 @@ char[] toUTF8(return out char[4] buf, dchar c) nothrow @nogc @safe pure * See_Also: * For a lazy, non-allocating version of these functions, see $(LREF byUTF). */ -string toUTF8(S)(S s) if (isInputRange!S && !isInfinite!S && isSomeChar!(ElementEncodingType!S)) +string toUTF8(S)(S s) +if (isInputRange!S && !isInfinite!S && isSomeChar!(ElementEncodingType!S)) { return toUTFImpl!string(s); } @@ -2775,7 +2780,8 @@ body * See_Also: * For a lazy, non-allocating version of these functions, see $(LREF byUTF). */ -wstring toUTF16(S)(S s) if (isInputRange!S && !isInfinite!S && isSomeChar!(ElementEncodingType!S)) +wstring toUTF16(S)(S s) +if (isInputRange!S && !isInfinite!S && isSomeChar!(ElementEncodingType!S)) { return toUTFImpl!wstring(s); } @@ -2817,7 +2823,8 @@ wstring toUTF16(S)(S s) if (isInputRange!S && !isInfinite!S && isSomeChar!(Eleme * See_Also: * For a lazy, non-allocating version of these functions, see $(LREF byUTF). */ -dstring toUTF32(S)(S s) if (isInputRange!S && !isInfinite!S && isSomeChar!(ElementEncodingType!S)) +dstring toUTF32(S)(S s) +if (isInputRange!S && !isInfinite!S && isSomeChar!(ElementEncodingType!S)) { return toUTFImpl!dstring(s); } @@ -2902,9 +2909,9 @@ template toUTFz(P) } private P toUTFzImpl(P, S)(S str) @safe pure - if (isSomeString!S && isPointer!P && isSomeChar!(typeof(*P.init)) && - is(Unqual!(typeof(*P.init)) == Unqual!(ElementEncodingType!S)) && - is(immutable(Unqual!(ElementEncodingType!S)) == ElementEncodingType!S)) +if (isSomeString!S && isPointer!P && isSomeChar!(typeof(*P.init)) && + is(Unqual!(typeof(*P.init)) == Unqual!(ElementEncodingType!S)) && + is(immutable(Unqual!(ElementEncodingType!S)) == ElementEncodingType!S)) //immutable(C)[] -> C*, const(C)*, or immutable(C)* { if (str.empty) @@ -2947,9 +2954,9 @@ private P toUTFzImpl(P, S)(S str) @safe pure } private P toUTFzImpl(P, S)(S str) @safe pure - if (isSomeString!S && isPointer!P && isSomeChar!(typeof(*P.init)) && - is(Unqual!(typeof(*P.init)) == Unqual!(ElementEncodingType!S)) && - !is(immutable(Unqual!(ElementEncodingType!S)) == ElementEncodingType!S)) +if (isSomeString!S && isPointer!P && isSomeChar!(typeof(*P.init)) && + is(Unqual!(typeof(*P.init)) == Unqual!(ElementEncodingType!S)) && + !is(immutable(Unqual!(ElementEncodingType!S)) == ElementEncodingType!S)) //C[] or const(C)[] -> C*, const(C)*, or immutable(C)* { alias InChar = ElementEncodingType!S; @@ -2987,8 +2994,8 @@ private P toUTFzImpl(P, S)(S str) @safe pure } private P toUTFzImpl(P, S)(S str) @safe pure - if (isSomeString!S && isPointer!P && isSomeChar!(typeof(*P.init)) && - !is(Unqual!(typeof(*P.init)) == Unqual!(ElementEncodingType!S))) +if (isSomeString!S && isPointer!P && isSomeChar!(typeof(*P.init)) && + !is(Unqual!(typeof(*P.init)) == Unqual!(ElementEncodingType!S))) //C1[], const(C1)[], or immutable(C1)[] -> C2*, const(C2)*, or immutable(C2)* { import std.array : appender; @@ -3097,7 +3104,7 @@ private P toUTFzImpl(P, S)(S str) @safe pure that take an $(D LPWSTR) or $(D LPCWSTR) argument. +/ const(wchar)* toUTF16z(C)(const(C)[] str) @safe pure - if (isSomeChar!C) +if (isSomeChar!C) { return toUTFz!(const(wchar)*)(str); } @@ -3156,7 +3163,7 @@ const(wchar)* toUTF16z(C)(const(C)[] str) @safe pure $(D UTFException) if $(D str) is not well-formed. +/ size_t count(C)(const(C)[] str) @trusted pure nothrow @nogc - if (isSomeChar!C) +if (isSomeChar!C) { return walkLength(str); } @@ -3312,7 +3319,8 @@ enum dchar replacementDchar = '\uFFFD'; * For a range that iterates by grapheme cluster (written character) see * $(REF byGrapheme, std,uni). */ -auto byCodeUnit(R)(R r) if (isAutodecodableString!R) +auto byCodeUnit(R)(R r) +if (isAutodecodableString!R) { static struct ByCodeUnitImpl { @@ -3366,7 +3374,7 @@ auto byCodeUnit(R)(R r) if (isAutodecodableString!R) /// Ditto auto ref byCodeUnit(R)(R r) - if (!isAutodecodableString!R && isInputRange!R && isSomeChar!(ElementEncodingType!R)) +if (!isAutodecodableString!R && isInputRange!R && isSomeChar!(ElementEncodingType!R)) { // byCodeUnit for ranges and dchar[] is a no-op return r; @@ -3747,7 +3755,8 @@ int impureVariable; * * Otherwise, an input range of characters. */ -template byUTF(C) if (isSomeChar!C) +template byUTF(C) +if (isSomeChar!C) { static if (!is(Unqual!C == C)) alias byUTF = byUTF!(Unqual!C); diff --git a/std/uuid.d b/std/uuid.d index 6cb8b776f..12acc53ad 100644 --- a/std/uuid.d +++ b/std/uuid.d @@ -1312,13 +1312,15 @@ if (isInputRange!RNG && isIntegral!(ElementType!RNG)) * caused by a malformed UUID parsed at compile time can be cryptic, * but errors are detected and reported at compile time. */ -UUID parseUUID(T)(T uuidString) if (isSomeString!T) +UUID parseUUID(T)(T uuidString) +if (isSomeString!T) { return parseUUID(uuidString); } ///ditto -UUID parseUUID(Range)(ref Range uuidRange) if (isInputRange!Range +UUID parseUUID(Range)(ref Range uuidRange) +if (isInputRange!Range && is(Unqual!(ElementType!Range) == dchar)) { import std.conv : ConvException, parse; diff --git a/std/variant.d b/std/variant.d index 88767e116..560278e9f 100644 --- a/std/variant.d +++ b/std/variant.d @@ -2020,7 +2020,7 @@ unittest * parameter-less fallback function is specified. */ template visit(Handlers...) - if (Handlers.length > 0) +if (Handlers.length > 0) { /// auto visit(VariantType)(VariantType variant) @@ -2126,7 +2126,7 @@ unittest * when no parameter-less fallback function is specified. */ template tryVisit(Handlers...) - if (Handlers.length > 0) +if (Handlers.length > 0) { /// auto tryVisit(VariantType)(VariantType variant) @@ -2194,7 +2194,7 @@ unittest } private auto visitImpl(bool Strict, VariantType, Handler...)(VariantType variant) - if (isAlgebraic!VariantType && Handler.length > 0) +if (isAlgebraic!VariantType && Handler.length > 0) { alias AllowedTypes = VariantType.AllowedTypes; diff --git a/std/windows/syserror.d b/std/windows/syserror.d index adad3d396..dfa0c7eab 100644 --- a/std/windows/syserror.d +++ b/std/windows/syserror.d @@ -59,7 +59,7 @@ version (StdDdoc) +/ T wenforce(T, S)(T value, lazy S msg = null, string file = __FILE__, size_t line = __LINE__) @safe - if (isSomeString!S); + if (isSomeString!S); } else: @@ -147,7 +147,8 @@ class WindowsException : Exception T wenforce(T, S)(T value, lazy S msg = null, - string file = __FILE__, size_t line = __LINE__) if (isSomeString!S) +string file = __FILE__, size_t line = __LINE__) +if (isSomeString!S) { if (!value) throw new WindowsException(GetLastError(), to!string(msg), file, line);