diff --git a/std/algorithm.d b/std/algorithm.d index 7f39188e6..b5e88ced7 100644 --- a/std/algorithm.d +++ b/std/algorithm.d @@ -392,11 +392,11 @@ template map(fun...) if (fun.length >= 1) { import std.functional : adjoin; - alias adjoin!(staticMap!(unaryFun, fun)) _fun; + alias _fun = adjoin!(staticMap!(unaryFun, fun)); } else { - alias unaryFun!fun _fun; + alias _fun = unaryFun!fun; } return MapResult!(_fun, Range)(r); @@ -439,14 +439,13 @@ unittest { import std.conv : to; - alias map!(to!string) stringize; + alias stringize = map!(to!string); assert(equal(stringize([ 1, 2, 3, 4 ]), [ "1", "2", "3", "4" ])); } private struct MapResult(alias fun, Range) { - alias Unqual!Range R; - //alias typeof(fun(.ElementType!R.init)) ElementType; + alias R = Unqual!Range; R _input; static if (isBidirectionalRange!R) @@ -493,9 +492,9 @@ private struct MapResult(alias fun, Range) static if (isRandomAccessRange!R) { static if (is(typeof(_input[ulong.max]))) - private alias ulong opIndex_t; + private alias opIndex_t = ulong; else - private alias uint opIndex_t; + private alias opIndex_t = uint; auto ref opIndex(opIndex_t index) { @@ -510,7 +509,7 @@ private struct MapResult(alias fun, Range) return _input.length; } - alias length opDollar; + alias opDollar = length; } static if (hasSlicing!R) @@ -562,16 +561,16 @@ unittest debug(std_algorithm) scope(success) writeln("unittest @", __FILE__, ":", __LINE__, " done."); - alias map!(to!string) stringize; + alias stringize = map!(to!string); assert(equal(stringize([ 1, 2, 3, 4 ]), [ "1", "2", "3", "4" ])); uint counter; - alias map!((a) { return counter++; }) count; + alias count = map!((a) { return counter++; }); assert(equal(count([ 10, 2, 30, 4 ]), [ 0, 1, 2, 3 ])); counter = 0; adjoin!((a) { return counter++; }, (a) { return counter++; })(1); - alias map!((a) { return counter++; }, (a) { return counter++; }) countAndSquare; + alias countAndSquare = map!((a) { return counter++; }, (a) { return counter++; }); //assert(equal(countAndSquare([ 10, 2 ]), [ tuple(0u, 100), tuple(1u, 4) ])); } @@ -721,8 +720,8 @@ template reduce(fun...) if (fun.length >= 1) { static if (Args.length == 2) { - alias args[0] seed; - alias args[1] r; + alias seed = args[0]; + alias r = args[1]; Unqual!(Args[0]) result = seed; for (; !r.empty; r.popFront()) { @@ -744,7 +743,7 @@ template reduce(fun...) if (fun.length >= 1) { enforce(!args[$ - 1].empty, "Cannot reduce an empty range w/o an explicit seed value."); - alias args[0] r; + alias r = args[0]; static if (fun.length == 1) { auto seed = r.front; @@ -775,9 +774,9 @@ template reduce(fun...) if (fun.length >= 1) // copying, iterating by dchar over strings, and dealing with the // no explicit start value case would become an unreadable mess // if these were merged. - alias args[$ - 1] r; - alias Args[$ - 1] R; - alias ForeachType!R E; + alias r = args[$ - 1]; + alias R = Args[$ - 1]; + alias E = ForeachType!R; static if (args.length == 2) { @@ -1018,7 +1017,7 @@ Fills $(D range) with a $(D filler). void fill(Range, Value)(Range range, Value filler) if (isInputRange!Range && is(typeof(range.front = filler))) { - alias ElementType!Range T; + alias T = ElementType!Range; static if (is(typeof(range[] = filler))) { @@ -1068,7 +1067,7 @@ unittest //writeln(benchmark!(fun0, fun1, fun2)(10000)); // fill should accept InputRange - alias DummyRange!(ReturnBy.Reference, Length.No, RangeType.Input) InputRange; + alias InputRange = DummyRange!(ReturnBy.Reference, Length.No, RangeType.Input); enum filler = uint.max; InputRange range; fill(range, filler); @@ -1207,7 +1206,7 @@ unittest assert(a == [ 1, 2, 1, 2, 1 ]); // fill should accept InputRange - alias DummyRange!(ReturnBy.Reference, Length.No, RangeType.Input) InputRange; + alias InputRange = DummyRange!(ReturnBy.Reference, Length.No, RangeType.Input); InputRange range; fill(range,[1,2]); foreach (i,value;range.arr) @@ -1245,7 +1244,7 @@ assert(s == [ 42, 42, 42, 42, 42 ]); void uninitializedFill(Range, Value)(Range range, Value filler) if (isInputRange!Range && hasLvalueElements!Range && is(typeof(range.front = filler))) { - alias ElementType!Range T; + alias T = ElementType!Range; static if (hasElaborateAssign!T) { import std.conv : emplace; @@ -1280,7 +1279,7 @@ void initializeAll(Range)(Range range) { import core.stdc.string : memset, memcpy; - alias ElementType!Range T; + alias T = ElementType!Range; static if (hasElaborateAssign!T) { //Elaborate opAssign. Must go the memcpy road. @@ -1306,7 +1305,7 @@ void initializeAll(Range)(Range range) void initializeAll(Range)(Range range) if (is(Range == char[]) || is(Range == wchar[])) { - alias ElementEncodingType!Range T; + alias T = ElementEncodingType!Range; range[] = T.init; } @@ -1438,7 +1437,7 @@ unittest private struct FilterResult(alias pred, Range) { - alias Unqual!Range R; + alias R = Unqual!Range; R _input; this(R r) @@ -1608,7 +1607,7 @@ unittest private struct FilterBidiResult(alias pred, Range) { - alias Unqual!Range R; + alias R = Unqual!Range; R _input; this(R r) @@ -2309,7 +2308,7 @@ if (is(typeof(ElementType!Range.init == Separator.init)) Range _input; Separator _separator; // Do we need hasLength!Range? popFront uses _input.length... - alias typeof(unsigned(_input.length)) IndexType; + alias IndexType = typeof(unsigned(_input.length)); enum IndexType _unComputed = IndexType.max - 1, _atEnd = IndexType.max; IndexType _frontLength = _unComputed; IndexType _backLength = _unComputed; @@ -2561,7 +2560,7 @@ if (is(typeof(Range.init.front == Separator.init.front) : bool) private: Range _input; Separator _separator; - alias typeof(unsigned(_input.length)) RIndexType; + alias RIndexType = typeof(unsigned(_input.length)); // _frontLength == size_t.max means empty RIndexType _frontLength = RIndexType.max; static if (isBidirectionalRange!Range) @@ -3762,7 +3761,7 @@ struct Group(alias pred, R) if (isInputRange!R) { private R _input; private Tuple!(ElementType!R, uint) _current; - private alias binaryFun!pred comp; + private alias comp = binaryFun!pred; this(R input) { @@ -4240,9 +4239,9 @@ if (isForwardRange!R1 && isForwardRange!R2 { //return cast(R1) find(representation(haystack), representation(needle)); // Specialization for simple string search - alias Select!(haystack[0].sizeof == 1, ubyte[], - Select!(haystack[0].sizeof == 2, ushort[], uint[])) - Representation; + alias Representation = + Select!(haystack[0].sizeof == 1, ubyte[], + Select!(haystack[0].sizeof == 2, ushort[], uint[])); // Will use the array specialization return cast(R1) .find!(pred, Representation, Representation) (cast(Representation) haystack, cast(Representation) needle); @@ -4767,7 +4766,7 @@ public: return needle.length; } - alias length opDollar; + alias opDollar = length; } /// Ditto @@ -5329,7 +5328,7 @@ ptrdiff_t countUntil(alias pred, R)(R haystack) } else //Everything else { - alias ElementType!R T; //For narrow strings forces dchar iteration + alias T = ElementType!R; //For narrow strings forces dchar iteration foreach (T elem; haystack) { if (unaryFun!pred(elem)) return i; @@ -5541,8 +5540,8 @@ if (isInputRange!Range && Needles.length > 1 && is(typeof(.startsWith!pred(doesThisStart, withOneOfThese[0])) : bool ) && is(typeof(.startsWith!pred(doesThisStart, withOneOfThese[1 .. $])) : uint)) { - alias doesThisStart haystack; - alias withOneOfThese needles; + alias haystack = doesThisStart; + alias needles = withOneOfThese; // Make one pass looking for empty ranges in needles foreach (i, Unused; Needles) @@ -5614,8 +5613,8 @@ if (isInputRange!R1 && isInputRange!R2 && is(typeof(binaryFun!pred(doesThisStart.front, withThis.front)) : bool)) { - alias doesThisStart haystack; - alias withThis needle; + alias haystack = doesThisStart; + alias needle = withThis; static if (is(typeof(pred) : string)) enum isDefaultPred = pred == "a == b"; @@ -5893,8 +5892,8 @@ if (isBidirectionalRange!Range && Needles.length > 1 && is(typeof(.endsWith!pred(doesThisEnd, withOneOfThese[0])) : bool) && is(typeof(.endsWith!pred(doesThisEnd, withOneOfThese[1 .. $])) : uint)) { - alias doesThisEnd haystack; - alias withOneOfThese needles; + alias haystack = doesThisEnd; + alias needles = withOneOfThese; // Make one pass looking for empty ranges in needles foreach (i, Unused; Needles) @@ -5960,8 +5959,8 @@ if (isBidirectionalRange!R1 && isBidirectionalRange!R2 && is(typeof(binaryFun!pred(doesThisEnd.back, withThis.back)) : bool)) { - alias doesThisEnd haystack; - alias withThis needle; + alias haystack = doesThisEnd; + alias needle = withThis; static if (is(typeof(pred) : string)) enum isDefaultPred = pred == "a == b"; @@ -6459,7 +6458,7 @@ size_t count(alias pred = "true", R)(R haystack) is(typeof(unaryFun!pred(haystack.front)) : bool)) { size_t result; - alias ElementType!R T; //For narrow strings forces dchar iteration + alias T = ElementType!R; //For narrow strings forces dchar iteration foreach (T elem; haystack) if (unaryFun!pred(elem)) ++result; return result; @@ -6810,24 +6809,24 @@ template MinType(T...) static if (T.length == 2) { static if (!is(typeof(T[0].min))) - alias CommonType!(T[0 .. 2]) MinType; + alias MinType = CommonType!(T[0 .. 2]); else { enum hasMostNegative = is(typeof(mostNegative!(T[0]))) && is(typeof(mostNegative!(T[1]))); static if (hasMostNegative && mostNegative!(T[1]) < mostNegative!(T[0])) - alias T[1] MinType; + alias MinType = T[1]; else static if (hasMostNegative && mostNegative!(T[1]) > mostNegative!(T[0])) - alias T[0] MinType; + alias MinType = T[0]; else static if (T[1].max < T[0].max) - alias T[1] MinType; + alias MinType = T[1]; else - alias T[0] MinType; + alias MinType = T[0]; } } else { - alias MinType!(MinType!(T[0 .. 2]), T[2 .. $]) MinType; + alias MinType = MinType!(MinType!(T[0 .. 2]), T[2 .. $]); } } @@ -6897,15 +6896,15 @@ template MaxType(T...) static if (T.length == 2) { static if (!is(typeof(T[0].min))) - alias CommonType!(T[0 .. 2]) MaxType; + alias MaxType = CommonType!(T[0 .. 2]); else static if (T[1].max > T[0].max) - alias T[1] MaxType; + alias MaxType = T[1]; else - alias T[0] MaxType; + alias MaxType = T[0]; } else { - alias MaxType!(MaxType!(T[0], T[1]), T[2 .. $]) MaxType; + alias MaxType = MaxType!(MaxType!(T[0], T[1]), T[2 .. $]); } } @@ -8521,7 +8520,7 @@ assert(arr == [ 1, 3, 5, 4, 5 ]); // alias move = .move, // Range)(Range r) // { -// alias Iterator!(Range) It; +// alias It = Iterator!(Range); // static void assignIter(It a, It b) { move(*b, *a); } // return range(begin(r), partitionold!(not!(pred), ss, assignIter, Range)(r)); // } @@ -8551,7 +8550,7 @@ assert(arr == [ 1, 3, 4, 5, 4, 5, 2 ]); // SwapStrategy ss = SwapStrategy.semistable, // Range, Value)(Range r, Value v) // { -// alias Iterator!(Range) It; +// alias It = Iterator!(Range); // bool comp(typeof(*It) a) { return !binaryFun!(pred)(a, v); } // static void assignIterB(It a, It b) { *a = *b; } // return range(begin(r), @@ -8601,7 +8600,7 @@ Range partition(alias predicate, if ((ss == SwapStrategy.stable && isRandomAccessRange!(Range)) || (ss != SwapStrategy.stable && isForwardRange!(Range))) { - alias unaryFun!(predicate) pred; + alias pred = unaryFun!(predicate); if (r.empty) return r; static if (ss == SwapStrategy.stable) { @@ -8611,7 +8610,7 @@ Range partition(alias predicate, return r; } const middle = r.length / 2; - alias .partition!(pred, ss, Range) recurse; + alias recurse = .partition!(pred, ss, Range); auto lower = recurse(r[0 .. middle]); auto upper = recurse(r[middle .. $]); bringToFront(lower, r[middle .. r.length - upper.length]); @@ -8775,7 +8774,7 @@ if (ss == SwapStrategy.unstable && isRandomAccessRange!Range // The algorithm is described in "Engineering a sort function" by // Jon Bentley et al, pp 1257. - alias binaryFun!less lessFun; + alias lessFun = binaryFun!less; size_t i, j, k = r.length, l = k; bigloop: @@ -9072,8 +9071,8 @@ sort(alias less = "a < b", SwapStrategy ss = SwapStrategy.unstable, Stable sorting uses TimSort, which needs to copy elements into a buffer, requiring assignable elements. +/ { - alias binaryFun!(less) lessFun; - alias typeof(lessFun(r.front, r.front)) LessRet; // instantiate lessFun + alias lessFun = binaryFun!(less); + alias LessRet = typeof(lessFun(r.front, r.front)); // instantiate lessFun static if (is(LessRet == bool)) { import std.conv : text; @@ -9205,7 +9204,7 @@ unittest @disable void opAssign(S value); } - alias S[] R; + alias R = S[]; R r = [S(3), S(2), S(1)]; static assert(hasSwappableElements!R); static assert(!hasAssignableElements!R); @@ -9244,14 +9243,14 @@ template multiSort(less...) //if (less.length > 1) static if (is(typeof(less[$ - 1]) == SwapStrategy)) { enum ss = less[$ - 1]; - alias less[0 .. $ - 1] funs; + alias funs = less[0 .. $ - 1]; } else { - alias SwapStrategy.unstable ss; - alias less funs; + alias ss = SwapStrategy.unstable; + alias funs = less; } - alias binaryFun!(funs[0]) lessFun; + alias lessFun = binaryFun!(funs[0]); static if (funs.length > 1) { @@ -9334,7 +9333,7 @@ private size_t getPivot(alias less, Range)(Range r) // then returns the index of the middle element. In effect, it uses the // median-of-three heuristic. - alias binaryFun!(less) pred; + alias pred = binaryFun!(less); immutable len = r.length; immutable size_t mid = len / 2; immutable uint result = ((cast(uint) (pred(r[0], r[mid]))) << 2) | @@ -9370,7 +9369,7 @@ private size_t getPivot(alias less, Range)(Range r) private void optimisticInsertionSort(alias less, Range)(Range r) { - alias binaryFun!(less) pred; + alias pred = binaryFun!(less); if (r.length < 2) { return; @@ -9438,7 +9437,7 @@ void swapAt(R)(R r, size_t i1, size_t i2) private void quickSortImpl(alias less, Range)(Range r, real depth) { - alias ElementType!(Range) Elem; + alias Elem = ElementType!(Range); enum size_t optimisticInsertionSortGetsBetter = 25; static assert(optimisticInsertionSortGetsBetter >= 1); @@ -9455,7 +9454,7 @@ private void quickSortImpl(alias less, Range)(Range r, real depth) const pivotIdx = getPivot!(less)(r); auto pivot = r[pivotIdx]; - alias binaryFun!(less) pred; + alias pred = binaryFun!(less); // partition swapAt(r, pivotIdx, r.length - 1); @@ -9498,7 +9497,7 @@ private template HeapSortImpl(alias less, Range) static assert(hasLength!Range); static assert(hasSwappableElements!Range || hasAssignableElements!Range); - alias binaryFun!less lessFun; + alias lessFun = binaryFun!less; void heapSort(Range r) { @@ -9563,9 +9562,9 @@ private template TimSortImpl(alias pred, R) static assert(hasSlicing!R); static assert(hasAssignableElements!R); - alias ElementType!R T; + alias T = ElementType!R; - alias binaryFun!pred less; + alias less = binaryFun!pred; bool greater(T a, T b){ return less(b, a); } bool greaterEqual(T a, T b){ return !less(a, b); } bool lessEqual(T a, T b){ return !less(b, a); } @@ -9988,12 +9987,12 @@ private template TimSortImpl(alias pred, R) body { size_t lower = 0, center = 1, upper = range.length; - alias center gap; + alias gap = center; static if (forwardReverse) { - static if (!lowerUpper) alias lessEqual comp; // reverse lower - static if (lowerUpper) alias less comp; // reverse upper + static if (!lowerUpper) alias comp = lessEqual; // reverse lower + static if (lowerUpper) alias comp = less; // reverse upper // Gallop Search Reverse while (gap <= upper) @@ -10020,8 +10019,8 @@ private template TimSortImpl(alias pred, R) } else { - static if (!lowerUpper) alias greater comp; // forward lower - static if (lowerUpper) alias greaterEqual comp; // forward upper + static if (!lowerUpper) alias comp = greater; // forward lower + static if (lowerUpper) alias comp = greaterEqual; // forward upper // Gallop Search Forward while (lower + gap < upper) @@ -10051,10 +10050,10 @@ private template TimSortImpl(alias pred, R) } } - alias gallopSearch!(false, false) gallopForwardLower; - alias gallopSearch!(false, true) gallopForwardUpper; - alias gallopSearch!(true, false) gallopReverseLower; - alias gallopSearch!(true, true) gallopReverseUpper; + alias gallopForwardLower = gallopSearch!(false, false); + alias gallopForwardUpper = gallopSearch!(false, true); + alias gallopReverseLower = gallopSearch!( true, false); + alias gallopReverseUpper = gallopSearch!( true, true); } unittest @@ -10515,7 +10514,7 @@ if (isRandomAccessRange!Range && !isInfinite!Range && import std.exception : enforce; import std.conv : to; - alias Unqual!(ElementType!RangeIndex) IndexType; + alias IndexType = Unqual!(ElementType!RangeIndex); enforce(r.length == index.length, "r and index must be same length for makeIndex."); static if (IndexType.sizeof < size_t.sizeof) @@ -10558,8 +10557,8 @@ unittest immutable(int)[] arr = [ 2, 3, 1, 5, 0 ]; // index using pointers auto index1 = new immutable(int)*[arr.length]; - alias typeof(arr) ImmRange; - alias typeof(index1) ImmIndex; + alias ImmRange = typeof(arr); + alias ImmIndex = typeof(index1); static assert(isForwardRange!(ImmRange)); static assert(isRandomAccessRange!(ImmIndex)); static assert(!isIntegral!(ElementType!(ImmIndex))); @@ -10678,11 +10677,11 @@ unittest SwapStrategy ss, SRange, TRange)(SRange source, TRange target) { - alias binaryFun!(less) lessFun; + alias lessFun = binaryFun!(less); static assert(ss == SwapStrategy.unstable, "Stable indexing not yet implemented"); - alias Iterator!(SRange) SIter; - alias std.iterator.ElementType!(TRange) TElem; + alias SIter = Iterator!(SRange); + alias TElem = std.iterator.ElementType!(TRange); enum usingInt = isIntegral!(TElem); static if (usingInt) @@ -10890,7 +10889,7 @@ unittest // SwapStrategy ss = SwapStrategy.unstable, // Range)(Range r) // { -// alias Iterator!(Range) Iter; +// alias Iter = Iterator!(Range); // auto result = new Iter[r.length]; // // assume collection already ordered // size_t i = 0; @@ -10899,7 +10898,7 @@ unittest // result[i++] = it; // } // // sort the index -// alias typeof(transform(*result[0])) Transformed; +// alias Transformed = typeof(transform(*result[0])); // static bool indirectLess(Transformed a, Transformed b) // { // return less(a, b); @@ -11185,7 +11184,7 @@ struct SetUnion(alias less = "a < b", Rs...) if (allSatisfy!(isInputRange, Rs)) { private: Rs _r; - alias binaryFun!(less) comp; + alias comp = binaryFun!(less); uint _crt; void adjustPosition(uint candidate = 0)() @@ -11218,7 +11217,7 @@ private: } public: - alias CommonType!(staticMap!(.ElementType, Rs)) ElementType; + alias ElementType = CommonType!(staticMap!(.ElementType, Rs)); this(Rs rs) { @@ -11285,7 +11284,7 @@ public: return result; } - alias length opDollar; + alias opDollar = length; } } @@ -11460,7 +11459,7 @@ struct SetDifference(alias less = "a < b", R1, R2) private: R1 r1; R2 r2; - alias binaryFun!(less) comp; + alias comp = binaryFun!(less); void adjustPosition() { @@ -11545,7 +11544,7 @@ private: R1 r1; R2 r2; //bool usingR2; - alias binaryFun!(less) comp; + alias comp = binaryFun!(less); void adjustPosition() { @@ -11758,8 +11757,8 @@ struct NWayUnion(alias less, RangeOfRanges) { import std.container : BinaryHeap; - private alias .ElementType!(.ElementType!RangeOfRanges) ElementType; - private alias binaryFun!less comp; + private alias ElementType = .ElementType!(.ElementType!RangeOfRanges); + private alias comp = binaryFun!less; private RangeOfRanges _ror; static bool compFront(.ElementType!RangeOfRanges a, .ElementType!RangeOfRanges b) @@ -11922,7 +11921,7 @@ void largestPartialIntersectionWeighted (RangeOfRanges ror, Range tgt, WeightsAA weights, SortOutput sorted = SortOutput.no) { if (tgt.empty) return; - alias ElementType!Range InfoType; + alias InfoType = ElementType!Range; bool heapComp(InfoType a, InfoType b) { return weights[a[0]] * a[1] > weights[b[0]] * b[1]; @@ -11999,7 +11998,7 @@ unittest { import std.container : Array; - alias Tuple!(uint, uint) T; + alias T = Tuple!(uint, uint); const Array!T arrayOne = Array!T( [ T(1,2), T(3,4) ] ); const Array!T arrayTwo = Array!T([ T(1,2), T(3,4) ] ); diff --git a/std/array.d b/std/array.d index 3e8a7a4f4..9d9bbbac2 100644 --- a/std/array.d +++ b/std/array.d @@ -28,7 +28,7 @@ a special case in an overload. ForeachType!Range[] array(Range)(Range r) if (isIterable!Range && !isNarrowString!Range && !isInfinite!Range) { - alias ForeachType!Range E; + alias E = ForeachType!Range; static if (hasLength!Range) { if(r.length == 0) return null; @@ -243,8 +243,8 @@ auto assocArray(Range)(Range r) if (isInputRange!Range && isTuple!(ElementType!Range) && ElementType!Range.length == 2) { - alias ElementType!Range.Types[0] KeyType; - alias ElementType!Range.Types[1] ValueType; + alias KeyType = ElementType!Range.Types[0]; + alias ValueType = ElementType!Range.Types[1]; ValueType[KeyType] aa; foreach (t; r) aa[t[0]] = t[1]; @@ -364,7 +364,7 @@ if(allSatisfy!(isIntegral, I)) to!string(sizes.length) ~ " dimensions specified for a " ~ to!string(nDimensions!T) ~ " dimensional array."); - alias typeof(T.init[0]) E; + alias E = typeof(T.init[0]); auto ptr = (__ctfe) ? { @@ -693,7 +693,7 @@ slice, returns that slice. Otherwise, returns the null slice. */ inout(T)[] overlap(T)(inout(T)[] r1, inout(T)[] r2) @trusted pure nothrow { - alias inout(T) U; + alias U = inout(T); static U* max(U* a, U* b) nothrow { return a > b ? a : b; } static U* min(U* a, U* b) nothrow { return a < b ? a : b; } @@ -1303,7 +1303,7 @@ returns a new array. For a lazy version, refer to $(XREF range, repeat). */ ElementEncodingType!S[] replicate(S)(S s, size_t n) if (isDynamicArray!S) { - alias ElementEncodingType!S[] RetType; + alias RetType = ElementEncodingType!S[]; // Optimization for return join(std.range.repeat(s, n)); if (n == 0) @@ -1529,8 +1529,8 @@ ElementEncodingType!(ElementType!RoR)[] join(RoR, R)(RoR ror, R sep) isInputRange!R && is(Unqual!(ElementType!(ElementType!RoR)) == Unqual!(ElementType!R))) { - alias ElementType!RoR RoRElem; - alias typeof(return) RetType; + alias RoRElem = ElementType!RoR; + alias RetType = typeof(return); if (ror.empty) return RetType.init; @@ -1544,7 +1544,7 @@ ElementEncodingType!(ElementType!RoR)[] join(RoR, R)(RoR ror, R sep) else static if (!isArray!R) auto sepArr = array(sep); else - alias sep sepArr; + alias sepArr = sep; auto result = appender!RetType(); static if(isForwardRange!RoR && @@ -1574,12 +1574,12 @@ ElementEncodingType!(ElementType!RoR)[] join(RoR)(RoR ror) if(isInputRange!RoR && isInputRange!(ElementType!RoR)) { - alias typeof(return) RetType; + alias RetType = typeof(return); if (ror.empty) return RetType.init; - alias ElementType!RoR R; + alias R = ElementType!RoR; auto result = appender!RetType(); static if(isForwardRange!RoR && (hasLength!R || isNarrowString!R)) { @@ -1692,7 +1692,7 @@ unittest assert(join([[1, 2], [41, 42]]) == [1, 2, 41, 42]); assert(join(cast(int[][])[]).empty); - alias filter!"true" f; + alias f = filter!"true"; assert(join([[1, 2], [41, 42]], [5, 6]) == [1, 2, 5, 6, 41, 42]); assert(join(f([[1, 2], [41, 42]]), [5, 6]) == [1, 2, 5, 6, 41, 42]); assert(join([f([1, 2]), f([41, 42])], [5, 6]) == [1, 2, 5, 6, 41, 42]); @@ -1792,7 +1792,7 @@ unittest } foreach (S; TypeTuple!(string, wstring, dstring, char[], wchar[], dchar[])) { - alias ElementEncodingType!S Char; + alias Char = ElementEncodingType!S; S s = to!S("yet another dummy text, yet another ..."); S from = to!S("yet another"); S into = to!S("some"); @@ -2068,7 +2068,7 @@ unittest foreach(S; TypeTuple!(string, wstring, dstring, char[], wchar[], dchar[], const(char[]), immutable(char[]))) { - alias Unqual!S T; + alias T = Unqual!S; auto s = to!S("This is a foo foo list"); auto from = to!T("foo"); @@ -2350,7 +2350,7 @@ struct Appender(A : T[], T) // Const fixing hack. void put(Range)(Range items) if (canPutConstRange!Range) { - alias put!(Unqual!Range) p; + alias p = put!(Unqual!Range); p(items); } @@ -2542,7 +2542,7 @@ struct RefAppender(A : T[], T) mixin("return impl." ~ fn ~ "(args);"); } - private alias Appender!(A, T) AppenderType; + private alias AppenderType = Appender!(A, T); /** * Appends one item to the managed array. diff --git a/std/base64.d b/std/base64.d index 5613f9ef2..270bd2c73 100644 --- a/std/base64.d +++ b/std/base64.d @@ -53,13 +53,13 @@ version(unittest) import std.algorithm, std.conv, std.file, std.stdio; /** * The Base64 */ -alias Base64Impl!('+', '/') Base64; +alias Base64 = Base64Impl!('+', '/'); /** * The "URL and Filename safe" Base64 */ -alias Base64Impl!('-', '_') Base64URL; +alias Base64URL = Base64Impl!('-', '_'); /** @@ -67,8 +67,8 @@ alias Base64Impl!('-', '_') Base64URL; * * Example: * ----- - * alias Base64Impl!('+', '/') Base64; // The Base64 format(Already defined). - * alias Base64Impl!('!', '=', Base64.NoPadding) Base64Re; // non-standard Base64 format for Regular expression + * alias Base64 = Base64Impl!('+', '/'); // The Base64 format(Already defined). + * alias Base64Re = Base64Impl!('!', '=', Base64.NoPadding); // non-standard Base64 format for Regular expression * ----- * * NOTE: @@ -1422,7 +1422,7 @@ class Base64Exception : Exception unittest { - alias Base64Impl!('!', '=', Base64.NoPadding) Base64Re; + alias Base64Re = Base64Impl!('!', '=', Base64.NoPadding); // Test vectors from RFC 4648 ubyte[][string] tv = [ @@ -1646,7 +1646,7 @@ unittest } { // Encoder and Decoder for single character encoding and decoding - alias Base64Impl!('+', '/', Base64.NoPadding) Base64NoPadding; + alias Base64NoPadding = Base64Impl!('+', '/', Base64.NoPadding); auto tests = [ "" : ["", "", "", ""], diff --git a/std/bitmanip.d b/std/bitmanip.d index 202c08a06..bfe9136e5 100644 --- a/std/bitmanip.d +++ b/std/bitmanip.d @@ -77,7 +77,7 @@ private template createAccessors( { enum long minVal = -(1uL << (len - 1)); enum ulong maxVal = (1uL << (len - 1)) - 1; - alias Unsigned!(T) UT; + alias UT = Unsigned!(T); enum UT extendSign = cast(UT)~((~0uL) >> (64 - len)); } else @@ -141,17 +141,17 @@ private template createFields(string store, size_t offset, Ts...) static if (!Ts.length) { static if (offset == ubyte.sizeof * 8) - alias ubyte StoreType; + alias StoreType = ubyte; else static if (offset == ushort.sizeof * 8) - alias ushort StoreType; + alias StoreType = ushort; else static if (offset == uint.sizeof * 8) - alias uint StoreType; + alias StoreType = uint; else static if (offset == ulong.sizeof * 8) - alias ulong StoreType; + alias StoreType = ulong; else { static assert(false, "Field widths must sum to 8, 16, 32, or 64"); - alias ulong StoreType; // just to avoid another error msg + alias StoreType = ulong; // just to avoid another error msg } enum result = "private " ~ StoreType.stringof ~ " " ~ store ~ ";"; } @@ -3347,7 +3347,7 @@ unittest foreach(endianness; TypeTuple!(Endian.bigEndian, Endian.littleEndian)) { auto toWrite = appender!(ubyte[])(); - alias TypeTuple!(uint, int, long, ulong, short, ubyte, ushort, byte, uint) Types; + alias Types = TypeTuple!(uint, int, long, ulong, short, ubyte, ushort, byte, uint); ulong[] values = [42, -11, long.max, 1098911981329L, 16, 255, 19012, 2, 17]; assert(Types.length == values.length); diff --git a/std/c/process.d b/std/c/process.d index 334e2569d..650b50426 100644 --- a/std/c/process.d +++ b/std/c/process.d @@ -44,7 +44,7 @@ version (Windows) { uint _beginthread(void function(void *),uint,void *); - extern (Windows) alias uint function (void *) stdfp; + extern (Windows) alias stdfp = uint function (void *); uint _beginthreadex(void* security, uint stack_size, stdfp start_addr, void* arglist, uint initflag, diff --git a/std/c/windows/com.d b/std/c/windows/com.d index 4aa0f2fa1..f862e1025 100644 --- a/std/c/windows/com.d +++ b/std/c/windows/com.d @@ -8,8 +8,8 @@ import std.c.windows.windows; import std.string; alias WCHAR OLECHAR; -alias OLECHAR *LPOLESTR; -alias OLECHAR *LPCOLESTR; +alias LPOLESTR = OLECHAR*; +alias LPCOLESTR = OLECHAR*; enum { @@ -65,11 +65,11 @@ enum COINIT_DISABLE_OLE1DDE = 0x4, COINIT_SPEED_OVER_MEMORY = 0x8 } -alias DWORD COINIT; +alias COINIT = DWORD; enum RPC_E_CHANGED_MODE = 0x80010106; -alias const(GUID) IID; -alias const(GUID) CLSID; +alias IID = const(GUID); +alias CLSID = const(GUID); extern (C) { diff --git a/std/c/windows/winsock.d b/std/c/windows/winsock.d index 9028545f8..d85c48cbe 100644 --- a/std/c/windows/winsock.d +++ b/std/c/windows/winsock.d @@ -13,8 +13,8 @@ private import std.c.windows.windows; extern(Windows): -alias size_t SOCKET; -alias int socklen_t; +alias SOCKET = size_t; +alias socklen_t = int; const SOCKET INVALID_SOCKET = cast(SOCKET)~0; const int SOCKET_ERROR = -1; @@ -32,7 +32,7 @@ struct WSADATA USHORT iMaxUdpDg; char* lpVendorInfo; } -alias WSADATA* LPWSADATA; +alias LPWSADATA = WSADATA*; const int IOCPARM_MASK = 0x7F; @@ -226,7 +226,7 @@ struct fd_set_custom(uint SETSIZE) SOCKET[SETSIZE] fd_array; } -alias fd_set_custom!FD_SETSIZE fd_set; +alias fd_set = fd_set_custom!FD_SETSIZE; // Removes. void FD_CLR(SOCKET fd, fd_set* set) @@ -519,14 +519,14 @@ union in6_addr uint16_t[8] s6_addr16; uint32_t[4] s6_addr32; - alias s6_addr8 s6_addr; + alias s6_addr = s6_addr8; } const in6_addr IN6ADDR_ANY = { s6_addr8: [0] }; const in6_addr IN6ADDR_LOOPBACK = { s6_addr8: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1] }; -//alias IN6ADDR_ANY IN6ADDR_ANY_INIT; -//alias IN6ADDR_LOOPBACK IN6ADDR_LOOPBACK_INIT; +//alias IN6ADDR_ANY_INIT = IN6ADDR_ANY; +//alias IN6ADDR_LOOPBACK_INIT = IN6ADDR_LOOPBACK; const uint INET_ADDRSTRLEN = 16; const uint INET6_ADDRSTRLEN = 46; @@ -587,8 +587,8 @@ struct hostent } struct WSAOVERLAPPED; -alias WSAOVERLAPPED* LPWSAOVERLAPPED; -alias void function(DWORD, DWORD, LPWSAOVERLAPPED, DWORD) LPWSAOVERLAPPED_COMPLETION_ROUTINE; +alias LPWSAOVERLAPPED = WSAOVERLAPPED*; +alias LPWSAOVERLAPPED_COMPLETION_ROUTINE = void function(DWORD, DWORD, LPWSAOVERLAPPED, DWORD); int WSAIoctl(SOCKET s, DWORD dwIoControlCode, LPVOID lpvInBuffer, DWORD cbInBuffer, LPVOID lpvOutBuffer, DWORD cbOutBuffer, diff --git a/std/complex.d b/std/complex.d index 80e77e08f..784732f39 100644 --- a/std/complex.d +++ b/std/complex.d @@ -267,7 +267,7 @@ struct Complex(T) if (isFloatingPoint!T) // complex op complex Complex!(CommonType!(T,R)) opBinary(string op, R)(Complex!R z) const { - alias typeof(return) C; + alias C = typeof(return); auto w = C(this.re, this.im); return w.opOpAssign!(op)(z); } @@ -276,7 +276,7 @@ struct Complex(T) if (isFloatingPoint!T) Complex!(CommonType!(T,R)) opBinary(string op, R)(R r) const if (isNumeric!R) { - alias typeof(return) C; + alias C = typeof(return); auto w = C(this.re, this.im); return w.opOpAssign!(op)(r); } @@ -300,7 +300,7 @@ struct Complex(T) if (isFloatingPoint!T) if (op == "/" && isNumeric!R) { typeof(return) w; - alias FPTemporary!(typeof(w.re)) Tmp; + alias Tmp = FPTemporary!(typeof(w.re)); if (fabs(re) < fabs(im)) { @@ -684,7 +684,7 @@ unittest */ template Complex(T) if (is(T R == Complex!R)) { - alias T Complex; + alias Complex = T; } unittest diff --git a/std/concurrency.d b/std/concurrency.d index ba88b15d4..6e12f4484 100644 --- a/std/concurrency.d +++ b/std/concurrency.d @@ -142,7 +142,7 @@ private auto map(Op)( Op op ) { - alias ParameterTypeTuple!(Op) Args; + alias Args = ParameterTypeTuple!(Op); static if( Args.length == 1 ) { @@ -163,8 +163,8 @@ private foreach( i, t1; T ) { static assert( isFunctionPointer!t1 || isDelegate!t1 ); - alias ParameterTypeTuple!(t1) a1; - alias ReturnType!(t1) r1; + alias a1 = ParameterTypeTuple!(t1); + alias r1 = ReturnType!(t1); static if( i < T.length - 1 && is( r1 == void ) ) { @@ -175,7 +175,7 @@ private foreach( t2; T[i+1 .. $] ) { static assert( isFunctionPointer!t2 || isDelegate!t2 ); - alias ParameterTypeTuple!(t2) a2; + alias a2 = ParameterTypeTuple!(t2); static assert( !is( a1 == a2 ), "function with arguments " ~ a1.stringof ~ @@ -372,8 +372,8 @@ private template isSpawnable(F, T...) { template isParamsImplicitlyConvertible(F1, F2, int i=0) { - alias ParameterTypeTuple!F1 param1; - alias ParameterTypeTuple!F2 param2; + alias param1 = ParameterTypeTuple!F1; + alias param2 = ParameterTypeTuple!F2; static if (param1.length != param2.length) enum isParamsImplicitlyConvertible = false; else static if (param1.length == i) @@ -673,9 +673,9 @@ unittest private template receiveOnlyRet(T...) { static if( T.length == 1 ) - alias T[0] receiveOnlyRet; + alias receiveOnlyRet = T[0]; else - alias Tuple!(T) receiveOnlyRet; + alias receiveOnlyRet = Tuple!(T); } /** @@ -1127,16 +1127,16 @@ private static if( isImplicitlyConvertible!(T[0], Duration) ) { - alias TypeTuple!(T[1 .. $]) Ops; - alias vals[1 .. $] ops; + alias Ops = TypeTuple!(T[1 .. $]); + alias ops = vals[1 .. $]; assert( vals[0] >= dur!"msecs"(0) ); enum timedWait = true; Duration period = vals[0]; } else { - alias TypeTuple!(T) Ops; - alias vals[0 .. $] ops; + alias Ops = TypeTuple!(T); + alias ops = vals[0 .. $]; enum timedWait = false; } @@ -1144,7 +1144,7 @@ private { foreach( i, t; Ops ) { - alias ParameterTypeTuple!(t) Args; + alias Args = ParameterTypeTuple!(t); auto op = ops[i]; if( msg.convertsTo!(Args) ) @@ -1418,8 +1418,8 @@ private ////////////////////////////////////////////////////////////////////// - alias bool function(Tid) OnMaxFn; - alias List!(Message) ListT; + alias OnMaxFn = bool function(Tid); + alias ListT = List!(Message); private: ////////////////////////////////////////////////////////////////////// diff --git a/std/container.d b/std/container.d index c4ce19fd7..80cb9c4a4 100644 --- a/std/container.d +++ b/std/container.d @@ -261,7 +261,7 @@ struct TotalContainer(T) If the container has a notion of key-value mapping, $(D KeyType) defines the type of the key of the container. */ - alias T KeyType; + alias KeyType = T; /** If the container has a notion of multikey-value mapping, $(D @@ -271,7 +271,7 @@ the type of the $(D k)th key of the container. A container may define both $(D KeyType) and $(D KeyTypes), e.g. in the case it has the notion of primary/preferred key. */ - alias TypeTuple!T KeyTypes; + alias KeyTypes = TypeTuple!T; /** If the container has a notion of key-value mapping, $(D ValueType) @@ -279,7 +279,7 @@ defines the type of the value of the container. Typically, a map-style container mapping values of type $(D K) to values of type $(D V) defines $(D KeyType) to be $(D K) and $(D ValueType) to be $(D V). */ - alias T ValueType; + alias ValueType = T; /** Defines the container's primary range, which embodies one of the @@ -844,7 +844,7 @@ assert(equal(arr[], [4, 2, 3, 1])); auto rbt = make!(RedBlackTree!(int, "a > b"))([4, 2, 3, 1]); assert(equal(rbt[], [4, 3, 2, 1])); -alias make!(DList!int) makeList; +alias makeList = make!(DList!int); auto list = makeList([1, 7, 42]); assert(equal(list[], [1, 7, 42])); -------------------- @@ -874,7 +874,7 @@ unittest auto rbt = make!(RedBlackTree!(int, "a > b"))([4, 2, 3, 1]); assert(equal(rbt[], [4, 3, 2, 1])); - alias make!(DList!int) makeList; + alias makeList = make!(DList!int); auto list = makeList([1, 7, 42]); assert(equal(list[], [1, 7, 42])); } @@ -1177,13 +1177,13 @@ Complexity: $(BIGOH m), where $(D m) is the length of $(D stuff) } /// ditto - alias insertFront insert; + alias insert = insertFront; /// ditto - alias insert stableInsert; + alias stableInsert = insert; /// ditto - alias insertFront stableInsertFront; + alias stableInsertFront = insertFront; /** Picks one value from the front of the container, removes it from the @@ -1203,7 +1203,7 @@ Complexity: $(BIGOH 1). return result; } /// ditto - alias removeAny stableRemoveAny; + alias stableRemoveAny = removeAny; /** Removes the value at the front of the container. The stable version @@ -1221,7 +1221,7 @@ Complexity: $(BIGOH 1). } /// ditto - alias removeFront stableRemoveFront; + alias stableRemoveFront = removeFront; /** Removes $(D howMany) values at the front or back of the @@ -1248,7 +1248,7 @@ Complexity: $(BIGOH howMany * log(n)). } /// ditto - alias removeFront stableRemoveFront; + alias stableRemoveFront = removeFront; /** Inserts $(D stuff) after range $(D r), which must be a range @@ -1332,7 +1332,7 @@ $(D r) and $(D m) is the length of $(D stuff). } /// ditto - alias insertAfter stableInsertAfter; + alias stableInsertAfter = insertAfter; /** Removes a range from the list in linear time. @@ -1387,7 +1387,7 @@ Complexity: $(BIGOH n) } /// ditto - alias linearRemove stableLinearRemove; + alias stableLinearRemove = linearRemove; } unittest @@ -1930,16 +1930,16 @@ Complexity: $(BIGOH log(n)) } /// ditto - alias insertBack insert; + alias insert = insertBack; /// ditto - alias insert stableInsert; + alias stableInsert = insert; /// ditto - alias insertFront stableInsertFront; + alias stableInsertFront = insertFront; /// ditto - alias insertBack stableInsertBack; + alias stableInsertBack = insertBack; /** Picks one value from the front of the container, removes it from the @@ -1966,7 +1966,7 @@ Complexity: $(BIGOH 1). return result; } /// ditto - alias removeAny stableRemoveAny; + alias stableRemoveAny = removeAny; /** Removes the value at the front/back of the container. The stable version @@ -1991,7 +1991,7 @@ Complexity: $(BIGOH 1). } /// ditto - alias removeFront stableRemoveFront; + alias stableRemoveFront = removeFront; /// ditto void removeBack() @@ -2005,7 +2005,7 @@ Complexity: $(BIGOH 1). } /// ditto - alias removeBack stableRemoveBack; + alias stableRemoveBack = removeBack; /** Removes $(D howMany) values at the front or back of the @@ -2039,7 +2039,7 @@ Complexity: $(BIGOH howMany * log(n)). } /// ditto - alias removeFront stableRemoveFront; + alias stableRemoveFront = removeFront; /// ditto size_t removeBack(size_t howMany) @@ -2058,7 +2058,7 @@ Complexity: $(BIGOH howMany * log(n)). } /// ditto - alias removeBack stableRemoveBack; + alias stableRemoveBack = removeBack; /** Inserts $(D stuff) after range $(D r), which must be a non-empty range @@ -2084,7 +2084,7 @@ $(D r) and $(D m) is the length of $(D stuff). } /// ditto - alias insertBefore stableInsertBefore; + alias stableInsertBefore = insertBefore; /// ditto size_t insertAfter(Stuff)(Range r, Stuff stuff) @@ -2094,7 +2094,7 @@ $(D r) and $(D m) is the length of $(D stuff). } /// ditto - alias insertAfter stableInsertAfter; + alias stableInsertAfter = insertAfter; // Helper: insert $(D stuff) before Node $(D n). If $(D n) is $(D null) then insert at end. private size_t insertBeforeNode(Stuff)(Node* n, Stuff stuff) @@ -2275,9 +2275,9 @@ Complexity: $(BIGOH r.walkLength) /** $(RED Scheduled for deprecation. These methods are not actually stable. Use the standard $(D remove) or $(D linearRemove) instead.) */ - alias remove stableRemove; + alias stableRemove = remove; /// ditto - alias linearRemove stableLinearRemove; + alias stableLinearRemove = linearRemove; } unittest @@ -2313,7 +2313,7 @@ unittest unittest { - alias DList!int IntList; + alias IntList = DList!int; IntList list = IntList([0,1,2,3]); assert(equal(list[],[0,1,2,3])); list.insertBack([4,5,6,7]); @@ -2328,7 +2328,7 @@ unittest unittest { - alias DList!int IntList; + alias IntList = DList!int; IntList list = IntList([0,1,2,3]); auto range = list[]; for( ; !range.empty; range.popFront()) @@ -2647,7 +2647,7 @@ if (!is(Unqual!T == bool)) return result; } } - private alias RefCounted!(Payload, RefCountedAutoInitialize.no) Data; + private alias Data = RefCounted!(Payload, RefCountedAutoInitialize.no); private Data _data; /** @@ -3179,7 +3179,7 @@ Complexity: $(BIGOH log(n)). return result; } /// ditto - alias removeAny stableRemoveAny; + alias stableRemoveAny = removeAny; /** Inserts $(D value) to the front or back of the container. $(D stuff) @@ -3200,7 +3200,7 @@ elements in $(D stuff) return _data.insertBack(stuff); } /// ditto - alias insertBack insert; + alias insert = insertBack; /** Removes the value at the back of the container. The stable version @@ -3222,7 +3222,7 @@ Complexity: $(BIGOH log(n)). _data._payload = _data._payload[0 .. $ - 1]; } /// ditto - alias removeBack stableRemoveBack; + alias stableRemoveBack = removeBack; /** Removes $(D howMany) values at the front or back of the @@ -3252,7 +3252,7 @@ Complexity: $(BIGOH howMany). return howMany; } /// ditto - alias removeBack stableRemoveBack; + alias stableRemoveBack = removeBack; /** Inserts $(D stuff) before, after, or instead range $(D r), which must @@ -3397,7 +3397,7 @@ $(D r) return this[length - tailLength .. length]; } /// ditto - alias remove stableLinearRemove; + alias stableLinearRemove = remove; } unittest @@ -3496,7 +3496,7 @@ unittest { auto a = Array!int(0, 1, 2, 3, 4, 5, 6)[]; auto b = Array!int(6, 5, 4, 3, 2, 1, 0)[]; - alias typeof(a) A; + alias A = typeof(a); static assert(isRandomAccessRange!A); static assert(hasSlicing!A); @@ -3524,7 +3524,7 @@ version(unittest) } unittest { - alias structBug5920 S; + alias S = structBug5920; uint dMask; auto arr = Array!S(cast(S[])[]); @@ -3769,7 +3769,7 @@ if (isRandomAccessRange!(Store) || isRandomAccessRange!(typeof(Store.init[]))) } private RefCounted!(Data, RefCountedAutoInitialize.no) _payload; // Comparison predicate - private alias binaryFun!(less) comp; + private alias comp = binaryFun!(less); // Convenience accessors private @property ref Store _store() { @@ -4635,17 +4635,17 @@ if (is(Unqual!T == bool)) Complexity: $(BIGOH m * log(n)), where $(D m) is the number of elements in $(D stuff) */ - alias insertBack insert; + alias insert = insertBack; ///ditto - alias insertBack stableInsert; + alias stableInsert = insertBack; /** Same as $(D insert(stuff)) and $(D stableInsert(stuff)) respectively, but relax the complexity constraint to linear. */ - alias insertBack linearInsert; + alias linearInsert = insertBack; ///ditto - alias insertBack stableLinearInsert; + alias stableLinearInsert = insertBack; /** Picks one value in the container, removes it from the @@ -4666,7 +4666,7 @@ if (is(Unqual!T == bool)) return result; } /// ditto - alias removeAny stableRemoveAny; + alias stableRemoveAny = removeAny; unittest { @@ -4729,7 +4729,7 @@ if (is(Unqual!T == bool)) else return stuff.length; } /// ditto - alias insertBack stableInsertBack; + alias stableInsertBack = insertBack; /** Removes the value at the front or back of the container. The @@ -4759,7 +4759,7 @@ if (is(Unqual!T == bool)) } } /// ditto - alias removeBack stableRemoveBack; + alias stableRemoveBack = removeBack; /** Removes $(D howMany) values at the front or back of the @@ -4825,7 +4825,7 @@ if (is(Unqual!T == bool)) return inserted; } /// ditto - alias insertBefore stableInsertBefore; + alias stableInsertBefore = insertBefore; unittest { @@ -4852,7 +4852,7 @@ if (is(Unqual!T == bool)) return inserted; } /// ditto - alias insertAfter stableInsertAfter; + alias stableInsertAfter = insertAfter; unittest { @@ -4880,7 +4880,7 @@ if (is(Unqual!T == bool)) return 1; } /// ditto - alias replace stableReplace; + alias stableReplace = replace; unittest { @@ -4909,7 +4909,7 @@ if (is(Unqual!T == bool)) return this[r._a .. length]; } /// ditto - alias linearRemove stableLinearRemove; + alias stableLinearRemove = linearRemove; } unittest @@ -4956,7 +4956,7 @@ struct RBNode(V) /* * Convenience alias */ - alias RBNode* Node; + alias Node = RBNode*; private Node _left; private Node _right; @@ -5540,7 +5540,7 @@ struct RBNode(V) final class RedBlackTree(T, alias less = "a < b", bool allowDuplicates = false) if(is(typeof(binaryFun!less(T.init, T.init)))) { - alias binaryFun!less _less; + alias _less = binaryFun!less; // BUG: this must come first in the struct due to issue 2810 @@ -5650,10 +5650,10 @@ final class RedBlackTree(T, alias less = "a < b", bool allowDuplicates = false) /** * Element type for the tree */ - alias T Elem; + alias Elem = T; // used for convenience - private alias RBNode!Elem.Node Node; + private alias Node = RBNode!Elem.Node; private Node _end; private Node _begin; @@ -5998,7 +5998,7 @@ final class RedBlackTree(T, alias less = "a < b", bool allowDuplicates = false) } /// ditto - alias stableInsert insert; + alias insert = stableInsert; static if(doUnittest) unittest { diff --git a/std/conv.d b/std/conv.d index 6b423ab5d..411e2d990 100644 --- a/std/conv.d +++ b/std/conv.d @@ -390,7 +390,7 @@ T toImpl(T, S)(S value) // Conversion between same size foreach (S; TypeTuple!(byte, short, int, long)) { - alias Unsigned!S U; + alias U = Unsigned!S; foreach (Sint; TypeTuple!(S, const S, immutable S)) foreach (Uint; TypeTuple!(U, const U, immutable U)) @@ -411,8 +411,8 @@ T toImpl(T, S)(S value) foreach (i, S1; TypeTuple!(byte, short, int, long)) foreach ( S2; TypeTuple!(byte, short, int, long)[i+1..$]) { - alias Unsigned!S1 U1; - alias Unsigned!S2 U2; + alias U1 = Unsigned!S1; + alias U2 = Unsigned!S2; static assert(U1.sizeof < S2.sizeof); @@ -694,18 +694,18 @@ T toImpl(T, S)(S value) // Unittest for 6288 @safe pure unittest { - template Identity(T) { alias T Identity; } - template toConst(T) { alias const(T) toConst; } - template toShared(T) { alias shared(T) toShared; } - template toSharedConst(T) { alias shared(const(T)) toSharedConst; } - template toImmutable(T) { alias immutable(T) toImmutable; } + alias Identity(T) = T; + alias toConst(T) = const T; + 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) { - static if (n == 0) alias Identity AddModifier; - else static if (n == 1) alias toConst AddModifier; - else static if (n == 2) alias toShared AddModifier; - else static if (n == 3) alias toSharedConst AddModifier; - else static if (n == 4) alias toImmutable AddModifier; + static if (n == 0) alias AddModifier = Identity; + else static if (n == 1) alias AddModifier = toConst; + else static if (n == 2) alias AddModifier = toShared; + else static if (n == 3) alias AddModifier = toSharedConst; + else static if (n == 4) alias AddModifier = toImmutable; } interface I {} @@ -719,8 +719,8 @@ T toImpl(T, S)(S value) foreach (m1; TypeTuple!(0,1,2,3,4)) // enumerate modifiers foreach (m2; TypeTuple!(0,1,2,3,4)) // ditto { - alias AddModifier!m1 srcmod; - alias AddModifier!m2 tgtmod; + alias srcmod = AddModifier!m1; + alias tgtmod = AddModifier!m2; //pragma(msg, srcmod!Object, " -> ", tgtmod!Object, ", convertible = ", // isImplicitlyConvertible!(srcmod!Object, tgtmod!Object)); @@ -823,7 +823,7 @@ T toImpl(T, S)(S value) else static if (is(S == void[]) || is(S == const(void)[]) || is(S == immutable(void)[])) { // Converting void array to string - alias Unqual!(ElementEncodingType!T) Char; + alias Char = Unqual!(ElementEncodingType!T); auto raw = cast(const(ubyte)[]) value; enforce(raw.length % Char.sizeof == 0, new ConvException("Alignment mismatch in converting a " @@ -915,16 +915,15 @@ if (is (T == immutable) && isExactSomeString!T && is(S == enum)) // string to string conversion debug(conv) scope(success) writeln("unittest @", __FILE__, ":", __LINE__, " succeeded."); - alias TypeTuple!(char, wchar, dchar) Chars; + alias Chars = TypeTuple!(char, wchar, dchar); foreach (LhsC; Chars) { - alias TypeTuple!(LhsC[], const(LhsC)[], immutable(LhsC)[]) LhStrings; + alias LhStrings = TypeTuple!(LhsC[], const(LhsC)[], immutable(LhsC)[]); foreach (Lhs; LhStrings) { foreach (RhsC; Chars) { - alias TypeTuple!(RhsC[], const(RhsC)[], immutable(RhsC)[]) - RhStrings; + alias RhStrings = TypeTuple!(RhsC[], const(RhsC)[], immutable(RhsC)[]); foreach (Rhs; RhStrings) { Lhs s1 = to!Lhs("wyda"); @@ -993,10 +992,10 @@ if (is (T == immutable) && isExactSomeString!T && is(S == enum)) // Conversion representing character value with string debug(conv) scope(success) writeln("unittest @", __FILE__, ":", __LINE__, " succeeded."); - alias TypeTuple!( - char, const( char), immutable( char), - wchar, const(wchar), immutable(wchar), - dchar, const(dchar), immutable(dchar)) AllChars; + alias AllChars = + TypeTuple!( char, const( char), immutable( char), + wchar, const(wchar), immutable(wchar), + dchar, const(dchar), immutable(dchar)); foreach (Char1; AllChars) { foreach (Char2; AllChars) @@ -1444,8 +1443,8 @@ T toImpl(T, S)(S value) { /* This code is potentially unsafe. */ - alias KeyType!T K2; - alias ValueType!T V2; + alias K2 = KeyType!T; + alias V2 = ValueType!T; // While we are "building" the AA, we need to unqualify its values, and only re-qualify at the end Unqual!V2[K2] result; @@ -2999,7 +2998,7 @@ Target parse(Target, Source)(ref Source s) @safe pure unittest { - alias typeof(null) NullType; + alias NullType = typeof(null); auto s1 = "null"; assert(parse!NullType(s1) is null); assert(s1 == ""); @@ -4602,7 +4601,7 @@ unittest unittest //@@@9559@@@ { - alias Nullable!int I; + alias I = Nullable!int; auto ints = [0, 1, 2].map!(i => i & 1 ? I.init : I(i))(); auto asArray = std.array.array(ints); } diff --git a/std/digest/crc.d b/std/digest/crc.d index 112a2e15f..5e74006df 100644 --- a/std/digest/crc.d +++ b/std/digest/crc.d @@ -317,9 +317,9 @@ auto crc32Of(T...)(T data) * This is a convenience alias for $(XREF digest.digest, toHexString) producing the usual * CRC32 string output. */ -public alias toHexString!(Order.decreasing) crcHexString; +public alias crcHexString = toHexString!(Order.decreasing); ///ditto -public alias toHexString!(Order.decreasing, 16) crcHexString; +public alias crcHexString = toHexString!(Order.decreasing, 16); /// unittest @@ -335,7 +335,7 @@ unittest * This is an alias for $(XREF digest.digest, WrapperDigest)!CRC32, see * $(XREF digest.digest, WrapperDigest) for more information. */ -alias WrapperDigest!CRC32 CRC32Digest; +alias CRC32Digest = WrapperDigest!CRC32; /// unittest diff --git a/std/digest/digest.d b/std/digest/digest.d index 46f28e0e8..3208b2d86 100644 --- a/std/digest/digest.d +++ b/std/digest/digest.d @@ -318,11 +318,12 @@ template DigestType(T) { static if(isDigest!T) { - alias ReturnType!(typeof( + alias DigestType = + ReturnType!(typeof( { T dig = void; return dig.finish(); - })) DigestType; + })); } else static assert(false, T.stringof ~ " is not a digest! (fails isDigest!T)"); diff --git a/std/digest/md.d b/std/digest/md.d index 571022bb8..00def7958 100644 --- a/std/digest/md.d +++ b/std/digest/md.d @@ -508,7 +508,7 @@ unittest * This is an alias for $(XREF digest.digest, WrapperDigest)!MD5, see * $(XREF digest.digest, WrapperDigest) for more information. */ -alias WrapperDigest!MD5 MD5Digest; +alias MD5Digest = WrapperDigest!MD5; /// unittest diff --git a/std/digest/ripemd.d b/std/digest/ripemd.d index 27211233e..1e59d4940 100644 --- a/std/digest/ripemd.d +++ b/std/digest/ripemd.d @@ -670,7 +670,7 @@ unittest * This is an alias for $(XREF digest.digest, WrapperDigest)!RIPEMD160, see * $(XREF digest.digest, WrapperDigest) for more information. */ -alias WrapperDigest!RIPEMD160 RIPEMD160Digest; +alias RIPEMD160Digest = WrapperDigest!RIPEMD160; /// unittest diff --git a/std/digest/sha.d b/std/digest/sha.d index 838f77605..5c411105f 100644 --- a/std/digest/sha.d +++ b/std/digest/sha.d @@ -174,7 +174,7 @@ struct SHA1 } else { - alias transformX86 transform; + alias transform = transformX86; } private: @@ -580,7 +580,7 @@ unittest * This is an alias for $(XREF digest.digest, WrapperDigest)!SHA1, see * $(XREF digest.digest, WrapperDigest) for more information. */ -alias WrapperDigest!SHA1 SHA1Digest; +alias SHA1Digest = WrapperDigest!SHA1; /// unittest diff --git a/std/encoding.d b/std/encoding.d index 2a262ca7e..922f14e58 100644 --- a/std/encoding.d +++ b/std/encoding.d @@ -647,12 +647,12 @@ template EncoderInstance(E) /** Defines various character sets. */ enum AsciiChar : ubyte { init } /// Ditto -alias immutable(AsciiChar)[] AsciiString; +alias AsciiString = immutable(AsciiChar)[]; template EncoderInstance(CharType : AsciiChar) { - alias AsciiChar E; - alias AsciiString EString; + alias E = AsciiChar; + alias EString = AsciiString; @property string encodingName() { @@ -730,12 +730,12 @@ enum Latin1Char : ubyte { init } Defines an Latin1-encoded string (as an array of $(D immutable(Latin1Char))). */ -alias immutable(Latin1Char)[] Latin1String; /// +alias Latin1String = immutable(Latin1Char)[]; /// template EncoderInstance(CharType : Latin1Char) { - alias Latin1Char E; - alias Latin1String EString; + alias E = Latin1Char; + alias EString = Latin1String; @property string encodingName() { @@ -806,12 +806,12 @@ enum Windows1252Char : ubyte { init } Defines an Windows1252-encoded string (as an array of $(D immutable(Windows1252Char))). */ -alias immutable(Windows1252Char)[] Windows1252String; /// +alias Windows1252String = immutable(Windows1252Char)[]; /// template EncoderInstance(CharType : Windows1252Char) { - alias Windows1252Char E; - alias Windows1252String EString; + alias E = Windows1252Char; + alias EString = Windows1252String; @property string encodingName() { @@ -907,8 +907,8 @@ template EncoderInstance(CharType : Windows1252Char) template EncoderInstance(CharType : char) { - alias char E; - alias immutable(char)[] EString; + alias E = char; + alias EString = immutable(char)[]; @property string encodingName() { @@ -1073,8 +1073,8 @@ template EncoderInstance(CharType : char) template EncoderInstance(CharType : wchar) { - alias wchar E; - alias immutable(wchar)[] EString; + alias E = wchar; + alias EString = immutable(wchar)[]; @property string encodingName() { @@ -1170,8 +1170,8 @@ template EncoderInstance(CharType : wchar) template EncoderInstance(CharType : dchar) { - alias dchar E; - alias immutable(dchar)[] EString; + alias E = dchar; + alias EString = immutable(dchar)[]; @property string encodingName() { diff --git a/std/exception.d b/std/exception.d index 1ac7b3096..4e6ccfd82 100644 --- a/std/exception.d +++ b/std/exception.d @@ -452,7 +452,7 @@ unittest errnoEnforce(s); - alias Exception E1; + alias E1 = Exception; static class E2 : Exception { this(string fn, size_t ln) { super("", fn, ln); } @@ -565,7 +565,7 @@ unittest unittest { - alias enforceEx!Exception enf; + alias enf = enforceEx!Exception; assertNotThrown(enf(true)); assertThrown(enf(false, "blah")); } diff --git a/std/file.d b/std/file.d index ab4531011..d2cf51b81 100644 --- a/std/file.d +++ b/std/file.d @@ -181,11 +181,11 @@ void[] read(in char[] name, size_t upTo = size_t.max) { version(Windows) { - alias TypeTuple!(GENERIC_READ, + alias defaults = + TypeTuple!(GENERIC_READ, FILE_SHARE_READ, (SECURITY_ATTRIBUTES*).init, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, - HANDLE.init) - defaults; + HANDLE.init); auto h = CreateFileW(std.utf.toUTF16z(name), defaults); cenforce(h != INVALID_HANDLE_VALUE, name); @@ -316,10 +316,10 @@ void write(in char[] name, const void[] buffer) { version(Windows) { - alias TypeTuple!(GENERIC_WRITE, 0, null, CREATE_ALWAYS, + alias defaults = + TypeTuple!(GENERIC_WRITE, 0, null, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, - HANDLE.init) - defaults; + HANDLE.init); auto h = CreateFileW(std.utf.toUTF16z(name), defaults); cenforce(h != INVALID_HANDLE_VALUE, name); @@ -355,9 +355,9 @@ void append(in char[] name, in void[] buffer) { version(Windows) { - alias TypeTuple!(GENERIC_WRITE,0,null,OPEN_ALWAYS, - FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN,HANDLE.init) - defaults; + alias defaults = + TypeTuple!(GENERIC_WRITE,0,null,OPEN_ALWAYS, + FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN,HANDLE.init); auto h = CreateFileW(std.utf.toUTF16z(name), defaults); @@ -687,15 +687,15 @@ void setTimes(in char[] name, { const ta = SysTimeToFILETIME(accessTime); const tm = SysTimeToFILETIME(modificationTime); - alias TypeTuple!(GENERIC_WRITE, + alias defaults = + TypeTuple!(GENERIC_WRITE, 0, null, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_ATTRIBUTE_DIRECTORY | FILE_FLAG_BACKUP_SEMANTICS, - HANDLE.init) - defaults; + HANDLE.init); auto h = CreateFileW(std.utf.toUTF16z(name), defaults); cenforce(h != INVALID_HANDLE_VALUE, name); @@ -1887,7 +1887,7 @@ assert(!de2.isFile); @property uint linkAttributes(); version(Windows) - alias void* stat_t; + alias stat_t = void*; /++ $(BLUE This function is Posix-Only.) diff --git a/std/format.d b/std/format.d index 7c01a2bc9..8d1c603db 100644 --- a/std/format.d +++ b/std/format.d @@ -572,7 +572,7 @@ uint formattedRead(R, Char, S...)(ref R r, const(Char)[] fmt, S args) // Input is empty, nothing to read return 0; } - alias typeof(*args[0]) A; + alias A = typeof(*args[0]); static if (isTuple!A) { foreach (i, T; A.Types) @@ -604,7 +604,7 @@ unittest template FormatSpec(Char) if (!is(Unqual!Char == Char)) { - alias FormatSpec!(Unqual!Char) FormatSpec; + alias FormatSpec = FormatSpec!(Unqual!Char); } /** @@ -1905,7 +1905,7 @@ if (is(DynamicArrayTypeOf!T) && !is(StringTypeOf!T) && !is(T == enum) && !hasToS } else static if (!isInputRange!T) { - alias Unqual!(ArrayTypeOf!T) U; + alias U = Unqual!(ArrayTypeOf!T); static assert(isInputRange!U); U val = obj; formatValue(w, val, f); @@ -2327,17 +2327,17 @@ if (is(StringTypeOf!T) && !is(T == enum)) static if (is(typeof(str[0]) : const(char))) { enum postfix = 'c'; - alias const(ubyte)[] IntArr; + alias IntArr = const(ubyte)[]; } else static if (is(typeof(str[0]) : const(wchar))) { enum postfix = 'w'; - alias const(ushort)[] IntArr; + alias IntArr = const(ushort)[]; } else static if (is(typeof(str[0]) : const(dchar))) { enum postfix = 'd'; - alias const(uint)[] IntArr; + alias IntArr = const(uint)[]; } formattedWrite(w, "x\"%(%02X %)\"%s", cast(IntArr)str, postfix); } @@ -3702,8 +3702,9 @@ unittest // } auto stream = appender!(char[])(); - alias TypeTuple!(byte, ubyte, short, ushort, int, uint, long, ulong, - float, double, real) AllNumerics; + alias AllNumerics = + TypeTuple!(byte, ubyte, short, ushort, int, uint, long, ulong, + float, double, real); foreach (T; AllNumerics) { T value = 1; @@ -3745,8 +3746,8 @@ void formatReflectTest(T)(ref T val, string fmt, string formatted, string fn = _ static if (isAssociativeArray!T) if (__ctfe) { - alias val aa1; - alias val2 aa2; + alias aa1 = val; + alias aa2 = val2; //assert(aa1 == aa2); assert(aa1.length == aa2.length); @@ -3792,8 +3793,8 @@ void formatReflectTest(T)(ref T val, string fmt, string[] formatted, string fn = static if (isAssociativeArray!T) if (__ctfe) { - alias val aa1; - alias val2 aa2; + alias aa1 = val; + alias aa2 = val2; //assert(aa1 == aa2); assert(aa1.length == aa2.length); diff --git a/std/functional.d b/std/functional.d index 52b187087..6a6edcef7 100644 --- a/std/functional.d +++ b/std/functional.d @@ -48,7 +48,7 @@ template unaryFun(alias fun, string parmName = "a") } else { - alias fun unaryFun; + alias unaryFun = fun; } } @@ -82,9 +82,9 @@ compared elements. Example: ---- -alias binaryFun!("a < b") less; +alias less = binaryFun!("a < b"); assert(less(1, 2) && !less(2, 1)); -alias binaryFun!("a > b") greater; +alias greater = binaryFun!("a > b"); assert(!greater("1", "2") && greater("2", "1")); ---- */ @@ -104,13 +104,13 @@ template binaryFun(alias fun, string parm1Name = "a", } else { - alias fun binaryFun; + alias binaryFun = fun; } } unittest { - alias binaryFun!(q{a < b}) less; + alias less = binaryFun!(q{a < b}); assert(less(1, 2) && !less(2, 1)); assert(less("1", "2") && !less("2", "1")); @@ -129,17 +129,17 @@ unittest Predicate that returns $(D_PARAM a < b). */ //bool less(T)(T a, T b) { return a < b; } -//alias binaryFun!(q{a < b}) less; +//alias less = binaryFun!(q{a < b}); /* Predicate that returns $(D_PARAM a > b). */ -//alias binaryFun!(q{a > b}) greater; +//alias greater = binaryFun!(q{a > b}); /* Predicate that returns $(D_PARAM a == b). */ -//alias binaryFun!(q{a == b}) equalTo; +//alias equalTo = binaryFun!(q{a == b}); /** Binary predicate that reverses the order of arguments, e.g., given @@ -156,13 +156,13 @@ template binaryReverseArgs(alias pred) unittest { - alias binaryReverseArgs!(binaryFun!("a < b")) gt; + alias gt = binaryReverseArgs!(binaryFun!("a < b")); assert(gt(2, 1) && !gt(1, 1)); int x = 42; bool xyz(int a, int b) { return a * x < b / x; } auto foo = &xyz; foo(4, 5); - alias binaryReverseArgs!(foo) zyx; + alias zyx = binaryReverseArgs!(foo); assert(zyx(5, 4) == foo(4, 5)); } @@ -259,12 +259,12 @@ unittest assert(curry!(funOneArg, 1)() == 1); static int funThreeArgs(int a, int b, int c) { return a + b + c; } - alias curry!(funThreeArgs, 1) funThreeArgs1; + alias funThreeArgs1 = curry!(funThreeArgs, 1); assert(funThreeArgs1(2, 3) == 6); static assert(!is(typeof(funThreeArgs1(2)))); enum xe = 5; - alias curry!(f2, xe) fe; + alias fe = curry!(f2, xe); static assert(fe(6) == 11); } @@ -276,7 +276,7 @@ unittest return x + y; } - alias curry!(add, 5) add5; + alias add5 = curry!(add, 5); assert(add5(6) == 11); static assert(!is(typeof(add5()))); static assert(!is(typeof(add5(6, 7)))); @@ -286,7 +286,7 @@ unittest assert(dg(6) == 11); int x = 5; - alias curry!(add, x) addX; + alias addX = curry!(add, x); assert(addX(6) == 11); static struct Callable @@ -312,11 +312,11 @@ unittest static assert(!is(typeof(curry!(tcallable, "5")(6)))); static A funOneArg(A)(A a) { return a; } - alias curry!(funOneArg, 1) funOneArg1; + alias funOneArg1 = curry!(funOneArg, 1); assert(funOneArg1() == 1); static auto funThreeArgs(A, B, C)(A a, B b, C c) { return a + b + c; } - alias curry!(funThreeArgs, 1) funThreeArgs1; + alias funThreeArgs1 = curry!(funThreeArgs, 1); assert(funThreeArgs1(2, 3) == 6); static assert(!is(typeof(funThreeArgs1(1)))); @@ -360,7 +360,7 @@ template adjoin(F...) if (F.length) } else { - alias typeof(F[0](a)) Head; + alias Head = typeof(F[0](a)); Tuple!(Head, typeof(.adjoin!(F[1..$])(a)).Types) result = void; foreach (i, Unused; result.Types) { @@ -384,7 +384,7 @@ unittest assert(x3[0] && x3[1] == 2 && x3[2] == 2); bool F4(int a) { return a != x1; } - alias adjoin!(F4) eff4; + alias eff4 = adjoin!(F4); static struct S { bool delegate(int) store; @@ -408,7 +408,7 @@ unittest // ~NaryFun!(fun, [letter[0] + 1], V[1..$]).args; // enum code = args ~ "return "~fun~";"; // } -// alias void Result; +// alias Result = void; // } // unittest @@ -431,7 +431,7 @@ unittest // unittest // { -// alias naryFun!("a + b") test; +// alias test = naryFun!("a + b"); // test(1, 2); // } @@ -454,13 +454,13 @@ template compose(fun...) { static if (fun.length == 1) { - alias unaryFun!(fun[0]) compose; + alias compose = unaryFun!(fun[0]); } else static if (fun.length == 2) { // starch - alias unaryFun!(fun[0]) fun0; - alias unaryFun!(fun[1]) fun1; + alias fun0 = unaryFun!(fun[0]); + alias fun1 = unaryFun!(fun[1]); // protein: the core composition operation typeof({ E a; return fun0(fun1(a)); }()) compose(E)(E a) @@ -471,7 +471,7 @@ template compose(fun...) else { // protein: assembling operations - alias compose!(fun[0], compose!(fun[1 .. $])) compose; + alias compose = compose!(fun[0], compose!(fun[1 .. $])); } } @@ -490,10 +490,7 @@ template compose(fun...) int[] a = pipe!(readText, split, map!(to!(int)))("file.txt"); ---- */ -template pipe(fun...) -{ - alias compose!(Reverse!(fun)) pipe; -} +alias pipe(fun...) = compose!(Reverse!(fun)); unittest { @@ -525,7 +522,7 @@ double transmogrify(int a, string b) { ... expensive computation ... } -alias memoize!transmogrify fastTransmogrify; +alias fastTransmogrify = memoize!transmogrify; unittest { auto slow = transmogrify(2, "hello"); @@ -546,7 +543,7 @@ Example: ---- ulong fib(ulong n) { - alias memoize!fib mfib; + alias mfib = memoize!fib; return n < 2 ? 1 : mfib(n - 2) + mfib(n - 1); } ... @@ -559,7 +556,7 @@ Example: ---- ulong fact(ulong n) { - alias memoize!fact mfact; + alias mfact = memoize!fact; return n < 2 ? 1 : n * mfact(n - 1); } ... @@ -575,7 +572,7 @@ ulong factImpl(ulong n) { return n < 2 ? 1 : n * mfact(n - 1); } -alias memoize!factImpl fact; +alias fact = memoize!factImpl; ... assert(fact(10) == 3628800); ---- @@ -586,7 +583,7 @@ table is found to be $(D maxSize), the table is simply cleared. Example: ---- // Memoize no more than 128 values of transmogrify -alias memoize!(transmogrify, 128) fastTransmogrify; +alias fastTransmogrify = memoize!(transmogrify, 128); ---- */ template memoize(alias fun, uint maxSize = uint.max) @@ -610,21 +607,21 @@ template memoize(alias fun, uint maxSize = uint.max) unittest { - alias memoize!(function double(double x) { return sqrt(x); }) msqrt; + alias msqrt = memoize!(function double(double x) { return sqrt(x); }); auto y = msqrt(2.0); assert(y == msqrt(2.0)); y = msqrt(4.0); assert(y == sqrt(4.0)); - // alias memoize!rgb2cmyk mrgb2cmyk; + // alias mrgb2cmyk = memoize!rgb2cmyk; // auto z = mrgb2cmyk([43, 56, 76]); // assert(z == mrgb2cmyk([43, 56, 76])); - //alias memoize!fib mfib; + //alias mfib = memoize!fib; static ulong fib(ulong n) { - alias memoize!fib mfib; + alias mfib = memoize!fib; return n < 2 ? 1 : mfib(n - 2) + mfib(n - 1); } @@ -633,7 +630,7 @@ unittest static ulong fact(ulong n) { - alias memoize!fact mfact; + alias mfact = memoize!fact; return n < 2 ? 1 : n * mfact(n - 1); } assert(fact(10) == 3628800); @@ -684,7 +681,7 @@ private struct DelegateFaker(F) { } } // Type information used by the generated code. - alias FuncInfo!(F) FuncInfo_doIt; + alias FuncInfo_doIt = FuncInfo!(F); // Generate the member function doIt(). mixin( std.typecons.MemberFunctionGenerator!(GeneratingPolicy!()) @@ -728,7 +725,7 @@ auto toDelegate(F)(auto ref F fp) if (isCallable!(F)) } else { - alias typeof(&(new DelegateFaker!(F)).doIt) DelType; + alias DelType = typeof(&(new DelegateFaker!(F)).doIt); static struct DelegateFields { union { diff --git a/std/getopt.d b/std/getopt.d index 45e328c0c..ac8d3aa9c 100644 --- a/std/getopt.d +++ b/std/getopt.d @@ -541,8 +541,8 @@ void handleOption(R)(string option, R receiver, ref string[] args, else static if (isAssociativeArray!(typeof(*receiver))) { // hash receiver - alias typeof(receiver.keys[0]) K; - alias typeof(receiver.values[0]) V; + alias K = typeof(receiver.keys[0]); + alias V = typeof(receiver.values[0]); auto j = std.string.indexOf(val, assignChar); auto key = val[0 .. j], value = val[j + 1 .. $]; (*receiver)[to!(K)(key)] = to!(V)(value); diff --git a/std/internal/math/biguintcore.d b/std/internal/math/biguintcore.d index 66e8f44aa..f3c601701 100644 --- a/std/internal/math/biguintcore.d +++ b/std/internal/math/biguintcore.d @@ -42,8 +42,8 @@ else import std.internal.math.biguintnoasm; } -alias multibyteAddSub!('+') multibyteAdd; -alias multibyteAddSub!('-') multibyteSub; +alias multibyteAdd = multibyteAddSub!('+'); +alias multibyteSub = multibyteAddSub!('-'); private import core.cpuid; @@ -65,11 +65,11 @@ immutable size_t FASTDIVLIMIT; // crossover to recursive division static if (BigDigit.sizeof == int.sizeof) { enum { LG2BIGDIGITBITS = 5, BIGDIGITSHIFTMASK = 31 }; - alias ushort BIGHALFDIGIT; + alias BIGHALFDIGIT = ushort; } else static if (BigDigit.sizeof == long.sizeof) { - alias uint BIGHALFDIGIT; + alias BIGHALFDIGIT = uint; enum { LG2BIGDIGITBITS = 6, BIGDIGITSHIFTMASK = 63 }; } else static assert(0, "Unsupported BigDigit size"); diff --git a/std/internal/math/biguintnoasm.d b/std/internal/math/biguintnoasm.d index 7f0d4f908..18fc7c303 100644 --- a/std/internal/math/biguintnoasm.d +++ b/std/internal/math/biguintnoasm.d @@ -18,7 +18,7 @@ module std.internal.math.biguintnoasm; public: -alias uint BigDigit; // A Bignum is an array of BigDigits. +alias BigDigit = uint; // A Bignum is an array of BigDigits. // Limits for when to switch between multiplication algorithms. enum : int { KARATSUBALIMIT = 10 }; // Minimum value for which Karatsuba is worthwhile. diff --git a/std/internal/math/biguintx86.d b/std/internal/math/biguintx86.d index c02f6a52e..f969a4c0d 100644 --- a/std/internal/math/biguintx86.d +++ b/std/internal/math/biguintx86.d @@ -91,7 +91,7 @@ unittest public: -alias uint BigDigit; // A Bignum is an array of BigDigits. Usually the machine word size. +alias BigDigit = uint; // A Bignum is an array of BigDigits. Usually the machine word size. // Limits for when to switch between multiplication algorithms. enum : int { KARATSUBALIMIT = 18 }; // Minimum value for which Karatsuba is worthwhile. diff --git a/std/json.d b/std/json.d index c77e52327..6ab1f5e9d 100644 --- a/std/json.d +++ b/std/json.d @@ -27,8 +27,8 @@ import std.exception; private { // Prevent conflicts from these generic names - alias std.utf.stride UTFStride; - alias std.utf.decode toUnicode; + alias UTFStride = std.utf.stride; + alias toUnicode = std.utf.decode; } /** diff --git a/std/math.d b/std/math.d index 4280f0669..7f3d6a634 100644 --- a/std/math.d +++ b/std/math.d @@ -1965,7 +1965,7 @@ real frexp(real value, out int exp) @trusted pure nothrow ushort* vu = cast(ushort*)&value; long* vl = cast(long*)&value; int ex; - alias floatTraits!(real) F; + alias F = floatTraits!(real); ex = vu[F.EXPPOS_SHORT] & F.EXPMASK; static if (real.mant_dig == 64) // real80 @@ -2215,8 +2215,8 @@ int ilogb(real x) @trusted nothrow return core.stdc.math.ilogbl(x); } -alias core.stdc.math.FP_ILOGB0 FP_ILOGB0; -alias core.stdc.math.FP_ILOGBNAN FP_ILOGBNAN; +alias FP_ILOGB0 = core.stdc.math.FP_ILOGB0; +alias FP_ILOGBNAN = core.stdc.math.FP_ILOGBNAN; /******************************************* @@ -3070,7 +3070,7 @@ real floor(real x) @trusted pure nothrow if (isNaN(x) || isInfinity(x) || x == 0.0) return x; - alias floatTraits!(real) F; + alias F = floatTraits!(real); auto vu = *cast(ushort[real.sizeof/2]*)(&x); // Find the exponent (power of 2) @@ -3268,7 +3268,7 @@ long lrint(real x) @trusted pure nothrow } else static if (real.mant_dig == 64) { - alias floatTraits!(real) F; + alias F = floatTraits!(real); long result; // Rounding limit when casting from real(80-bit) to ulong. @@ -3695,7 +3695,7 @@ assert(rint(1.1) == 1); */ struct FloatingPointControl { - alias uint RoundingMode; + alias RoundingMode = uint; /** IEEE rounding modes. * The default mode is roundToNearest. @@ -3966,7 +3966,7 @@ unittest bool isNaN(real x) @trusted pure nothrow { - alias floatTraits!(real) F; + alias F = floatTraits!(real); static if (real.mant_dig == 53) // double { ulong* p = cast(ulong *)&x; @@ -4010,7 +4010,7 @@ unittest int isFinite(real e) @trusted pure nothrow { - alias floatTraits!(real) F; + alias F = floatTraits!(real); ushort* pe = cast(ushort *)&e; return (pe[F.EXPPOS_SHORT] & F.EXPMASK) != F.EXPMASK; } @@ -4033,7 +4033,7 @@ unittest int isNormal(X)(X x) @trusted pure nothrow { - alias floatTraits!(X) F; + alias F = floatTraits!(X); static if(real.mant_dig == 106) // doubledouble { @@ -4111,7 +4111,7 @@ unittest int isSubnormal(real x) @trusted pure nothrow { - alias floatTraits!(real) F; + alias F = floatTraits!(real); static if (real.mant_dig == 53) { // double @@ -4154,7 +4154,7 @@ unittest bool isInfinity(real x) @trusted pure nothrow { - alias floatTraits!(real) F; + alias F = floatTraits!(real); static if (real.mant_dig == 53) { // double @@ -4257,7 +4257,7 @@ real copysign(real to, real from) @trusted pure nothrow ubyte* pto = cast(ubyte *)&to; const ubyte* pfrom = cast(ubyte *)&from; - alias floatTraits!(real) F; + alias F = floatTraits!(real); pto[F.SIGNPOS_BYTE] &= 0x7F; pto[F.SIGNPOS_BYTE] |= pfrom[F.SIGNPOS_BYTE] & 0x80; return to; @@ -4493,7 +4493,7 @@ debug(UnitTest) */ real nextUp(real x) @trusted pure nothrow { - alias floatTraits!(real) F; + alias F = floatTraits!(real); static if (real.mant_dig == 53) { // double @@ -5036,7 +5036,7 @@ real pow(I, F)(I x, F y) @trusted pure nothrow Unqual!(Largest!(F, G)) pow(F, G)(F x, G y) @trusted pure nothrow if (isFloatingPoint!(F) && isFloatingPoint!(G)) { - alias typeof(return) Float; + alias Float = typeof(return); static real impl(real x, real y) pure nothrow { @@ -5322,7 +5322,7 @@ int feqrel(X)(X x, X y) @trusted pure nothrow ushort *pb = cast(ushort *)(&y); ushort *pd = cast(ushort *)(&diff); - alias floatTraits!(X) F; + alias F = floatTraits!(X); // The difference in abs(exponent) between x or y and abs(x-y) // is equal to the number of significand bits of x which are @@ -5468,7 +5468,7 @@ body // The implementation is simple: cast x and y to integers, // average them (avoiding overflow), and cast the result back to a floating-point number. - alias floatTraits!(real) F; + alias F = floatTraits!(real); T u; static if (T.mant_dig==64) { // real80 @@ -5830,11 +5830,11 @@ unittest } // Included for backwards compatibility with Phobos1 -alias isNaN isnan; -alias isFinite isfinite; -alias isNormal isnormal; -alias isSubnormal issubnormal; -alias isInfinity isinf; +alias isnan = isNaN; +alias isfinite = isFinite; +alias isnormal = isNormal; +alias issubnormal = isSubnormal; +alias isinf = isInfinity; /* ********************************** * Building block functions, they diff --git a/std/net/curl.d b/std/net/curl.d index 782de775f..397b5eba0 100644 --- a/std/net/curl.d +++ b/std/net/curl.d @@ -868,7 +868,7 @@ private auto _decodeContent(T)(ubyte[] content, string encoding) } } -alias std.string.KeepTerminator KeepTerminator; +alias KeepTerminator = std.string.KeepTerminator; /++ struct ByLineBuffer(Char) { @@ -1583,10 +1583,10 @@ private mixin template Protocol() /// Value to return from $(D onSend)/$(D onReceive) delegates in order to /// pause a request - alias CurlReadFunc.pause requestPause; + alias requestPause = CurlReadFunc.pause; /// Value to return from onSend delegate in order to abort a request - alias CurlReadFunc.abort requestAbort; + alias requestAbort = CurlReadFunc.abort; static uint defaultAsyncStringBufferSize = 100; @@ -1662,7 +1662,7 @@ private mixin template Protocol() } /// Type of proxy - alias etc.c.curl.CurlProxy CurlProxy; + alias CurlProxy = etc.c.curl.CurlProxy; /** Proxy type * See: $(WEB curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTPROXY, _proxy_type) @@ -2030,7 +2030,7 @@ struct HTTP mixin Protocol; /// Authentication method equal to $(ECXREF curl, CurlAuth) - alias CurlAuth AuthMethod; + alias AuthMethod = CurlAuth; static private uint defaultMaxRedirects = 10; @@ -2125,7 +2125,7 @@ struct HTTP $(WEB www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.25, _RFC2616 Section 14.25) */ - alias CurlTimeCond TimeCond; + alias TimeCond = CurlTimeCond; /** Constructor taking the url as parameter. @@ -2247,10 +2247,10 @@ struct HTTP { /// Value to return from $(D onSend)/$(D onReceive) delegates in order to /// pause a request - alias CurlReadFunc.pause requestPause; + alias requestPause = CurlReadFunc.pause; /// Value to return from onSend delegate in order to abort a request - alias CurlReadFunc.abort requestAbort; + alias requestAbort = CurlReadFunc.abort; /** True if the instance is stopped. A stopped instance is not usable. @@ -2291,7 +2291,7 @@ struct HTTP @property void proxyPort(ushort port); /// Type of proxy - alias etc.c.curl.CurlProxy CurlProxy; + alias CurlProxy = etc.c.curl.CurlProxy; /** Proxy type * See: $(WEB curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTPROXY, _proxy_type) @@ -2894,10 +2894,10 @@ struct FTP { /// Value to return from $(D onSend)/$(D onReceive) delegates in order to /// pause a request - alias CurlReadFunc.pause requestPause; + alias requestPause = CurlReadFunc.pause; /// Value to return from onSend delegate in order to abort a request - alias CurlReadFunc.abort requestAbort; + alias requestAbort = CurlReadFunc.abort; /** True if the instance is stopped. A stopped instance is not usable. @@ -2938,7 +2938,7 @@ struct FTP @property void proxyPort(ushort port); /// Type of proxy - alias etc.c.curl.CurlProxy CurlProxy; + alias CurlProxy = etc.c.curl.CurlProxy; /** Proxy type * See: $(WEB curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTPROXY, _proxy_type) @@ -3234,10 +3234,10 @@ struct SMTP { /// Value to return from $(D onSend)/$(D onReceive) delegates in order to /// pause a request - alias CurlReadFunc.pause requestPause; + alias requestPause = CurlReadFunc.pause; /// Value to return from onSend delegate in order to abort a request - alias CurlReadFunc.abort requestAbort; + alias requestAbort = CurlReadFunc.abort; /** True if the instance is stopped. A stopped instance is not usable. @@ -3278,7 +3278,7 @@ struct SMTP @property void proxyPort(ushort port); /// Type of proxy - alias etc.c.curl.CurlProxy CurlProxy; + alias CurlProxy = etc.c.curl.CurlProxy; /** Proxy type * See: $(WEB curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTPROXY, _proxy_type) @@ -3471,7 +3471,7 @@ class CurlTimeoutException : CurlException } /// Equal to $(ECXREF curl, CURLcode) -alias CURLcode CurlCode; +alias CurlCode = CURLcode; /** Wrapper to provide a better interface to libcurl than using the plain C API. @@ -3497,8 +3497,8 @@ struct Curl curl_global_cleanup(); } - alias void[] OutData; - alias ubyte[] InData; + alias OutData = void[]; + alias InData = ubyte[]; bool stopped; // A handle should not be used by two threads simultaneously @@ -3513,8 +3513,8 @@ struct Curl private int delegate(size_t dltotal, size_t dlnow, size_t ultotal, size_t ulnow) _onProgress; - alias CurlReadFunc.pause requestPause; - alias CurlReadFunc.abort requestAbort; + alias requestPause = CurlReadFunc.pause; + alias requestAbort = CurlReadFunc.abort; /** Initialize the instance by creating a working curl handle. diff --git a/std/net/isemail.d b/std/net/isemail.d index d9baaebef..239e3801b 100644 --- a/std/net/isemail.d +++ b/std/net/isemail.d @@ -67,7 +67,7 @@ import std.uni; EmailStatus isEmail (Char) (const(Char)[] email, CheckDns checkDNS = CheckDns.no, EmailStatusCode errorLevel = EmailStatusCode.none) if (isSomeChar!(Char)) { - alias const(Char)[] tstring; + alias tstring = const(Char)[]; enum defaultThreshold = 16; int threshold; diff --git a/std/numeric.d b/std/numeric.d index 44c044f1d..41821b6d4 100644 --- a/std/numeric.d +++ b/std/numeric.d @@ -112,22 +112,23 @@ private template CustomFloatParams(uint bits) { enum CustomFloatFlags flags = CustomFloatFlags.ieee ^ ((bits == 80) ? CustomFloatFlags.storeNormalized : CustomFloatFlags.none); - static if (bits == 8) alias CustomFloatParams!( 4, 3, flags) CustomFloatParams; - static if (bits == 16) alias CustomFloatParams!(10, 5, flags) CustomFloatParams; - static if (bits == 32) alias CustomFloatParams!(23, 8, flags) CustomFloatParams; - static if (bits == 64) alias CustomFloatParams!(52, 11, flags) CustomFloatParams; - static if (bits == 80) alias CustomFloatParams!(64, 15, flags) CustomFloatParams; + static if (bits == 8) alias CustomFloatParams = CustomFloatParams!( 4, 3, flags); + static if (bits == 16) alias CustomFloatParams = CustomFloatParams!(10, 5, flags); + static if (bits == 32) alias CustomFloatParams = CustomFloatParams!(23, 8, flags); + static if (bits == 64) alias CustomFloatParams = CustomFloatParams!(52, 11, flags); + static if (bits == 80) alias CustomFloatParams = CustomFloatParams!(64, 15, flags); } private template CustomFloatParams(uint precision, uint exponentWidth, CustomFloatFlags flags) { - alias TypeTuple!( - precision, - exponentWidth, - flags, - (1 << (exponentWidth - ((flags & flags.probability) == 0))) - - ((flags & (flags.nan | flags.infinity)) != 0) - ((flags & flags.probability) != 0) - ) CustomFloatParams; // ((flags & CustomFloatFlags.probability) == 0) + alias CustomFloatParams = + TypeTuple!( + precision, + exponentWidth, + flags, + (1 << (exponentWidth - ((flags & flags.probability) == 0))) + - ((flags & (flags.nan | flags.infinity)) != 0) - ((flags & flags.probability) != 0) + ); // ((flags & CustomFloatFlags.probability) == 0) } /** @@ -155,20 +156,20 @@ private template CustomFloatParams(uint precision, uint exponentWidth, CustomFlo * z = sin(cast(float)x) + cos(cast(float)y); // Or use cast(T) to explicitly convert * * // Define a 8-bit custom float for storing probabilities - * alias CustomFloat!(4, 4, CustomFloatFlags.ieee^CustomFloatFlags.probability^CustomFloatFlags.signed ) Probability; + * alias Probability = CustomFloat!(4, 4, CustomFloatFlags.ieee^CustomFloatFlags.probability^CustomFloatFlags.signed ); * auto p = Probability(0.5); * ---- */ template CustomFloat(uint bits) if (bits == 8 || bits == 16 || bits == 32 || bits == 64 || bits == 80) { - alias CustomFloat!(CustomFloatParams!(bits)) CustomFloat; + 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) { - alias CustomFloat!(CustomFloatParams!(precision, exponentWidth, flags)) CustomFloat; + alias CustomFloat = CustomFloat!(CustomFloatParams!(precision, exponentWidth, flags)); } /// ditto struct CustomFloat( @@ -182,21 +183,21 @@ struct CustomFloat( private: // get the correct unsigned bitfield type to support > 32 bits template uType(uint bits) { - static if(bits <= size_t.sizeof*8) alias size_t uType; - else alias ulong uType; + static if(bits <= size_t.sizeof*8) alias uType = size_t; + else alias uType = ulong ; } // get the correct signed bitfield type to support > 32 bits template sType(uint bits) { - static if(bits <= ptrdiff_t.sizeof*8-1) alias ptrdiff_t sType; - else alias long sType; + static if(bits <= ptrdiff_t.sizeof*8-1) alias sType = ptrdiff_t; + else alias sType = long; } - alias uType!precision T_sig; - alias uType!exponentWidth T_exp; - alias sType!exponentWidth T_signed_exp; + alias T_sig = uType!precision; + alias T_exp = uType!exponentWidth; + alias T_signed_exp = sType!exponentWidth; - alias CustomFloatFlags Flags; + alias Flags = CustomFloatFlags; // Facilitate converting numeric types to custom float union ToBinary(F) @@ -556,13 +557,13 @@ struct CustomFloat( unittest { - alias TypeTuple!( - CustomFloat!(5, 10), - CustomFloat!(5, 11, CustomFloatFlags.ieee ^ CustomFloatFlags.signed), - CustomFloat!(1, 15, CustomFloatFlags.ieee ^ CustomFloatFlags.signed), - CustomFloat!(4, 3, CustomFloatFlags.ieee | CustomFloatFlags.probability ^ CustomFloatFlags.signed) - - ) FPTypes; + alias FPTypes = + TypeTuple!( + CustomFloat!(5, 10), + CustomFloat!(5, 11, CustomFloatFlags.ieee ^ CustomFloatFlags.signed), + CustomFloat!(1, 15, CustomFloatFlags.ieee ^ CustomFloatFlags.signed), + CustomFloat!(4, 3, CustomFloatFlags.ieee | CustomFloatFlags.probability ^ CustomFloatFlags.signed) + ); foreach (F; FPTypes) { @@ -627,7 +628,7 @@ on very many factors. */ template FPTemporary(F) if (isFloatingPoint!F) { - alias real FPTemporary; + alias FPTemporary = real; } /** @@ -1590,9 +1591,9 @@ unittest // { // ReturnType!(fun) tabulateFixed(ParameterTypeTuple!(fun) arg) // { -// alias ParameterTypeTuple!(fun)[0] num; +// alias num = ParameterTypeTuple!(fun)[0]; // static num[n] table; -// alias arg[0] x; +// alias x = arg[0]; // enforce(left <= x && x < right); // immutable i = cast(uint) (table.length // * ((x - left) / (right - left))); @@ -1618,7 +1619,7 @@ unittest // unittest // { // enum epsilon = 0.01; -// alias tabulateFixed!(tanh, 700, epsilon, 0.2, 3) fasttanh; +// alias fasttanh = tabulateFixed!(tanh, 700, epsilon, 0.2, 3); // uint testSize = 100000; // auto rnd = Random(unpredictableSeed); // foreach (i; 0 .. testSize) { @@ -2176,7 +2177,7 @@ unittest // though floats seem accurate enough for all practical purposes, since // they pass the "approxEqual(inverseFft(fft(arr)), arr)" test even for // size 2 ^^ 22. -private alias float lookup_t; +private alias lookup_t = float; /**A class for performing fast Fourier transforms of power of two sizes. * This class encapsulates a large amount of state that is reusable when @@ -2231,7 +2232,7 @@ private: assert(range.length >= 4); assert(isPowerOfTwo(range.length)); } body { - alias ElementType!R E; + alias E = ElementType!R; // Converts odd indices of range to the imaginary components of // a range half the size. The even indices become the real components. @@ -2244,7 +2245,7 @@ private: // source.length is even because it has to be a power of 2. static struct OddToImaginary { R source; - alias Complex!(CommonType!(E, typeof(buf[0].re))) C; + alias C = Complex!(CommonType!(E, typeof(buf[0].re))); @property { C front() { @@ -2506,7 +2507,7 @@ public: slowFourier2(range, buf); return; } else { - alias ElementType!R E; + alias E = ElementType!R; static if(is(E : real)) { return fftImplPureReal(range, buf); } else { @@ -2628,7 +2629,7 @@ unittest { assert(approxEqual(map!"a.re"(fft1), map!"a.re"(fft1Float))); assert(approxEqual(map!"a.im"(fft1), map!"a.im"(fft1Float))); - alias Complex!float C; + alias C = Complex!float; auto arr2 = [C(1,2), C(3,4), C(5,6), C(7,8), C(9,10), C(11,12), C(13,14), C(15,16)]; auto fft2 = fft(arr2); @@ -2689,7 +2690,7 @@ struct Stride(R) { Unqual!R range; size_t _nSteps; size_t _length; - alias ElementType!(R) E; + alias E = ElementType!(R); this(R range, size_t nStepsIn) { this.range = range; @@ -2765,7 +2766,7 @@ void slowFourier2(Ret, R)(R range, Ret buf) { // Hard-coded base case for FFT of size 4. Doesn't work as well as the size // 2 case. void slowFourier4(Ret, R)(R range, Ret buf) { - alias ElementType!Ret C; + alias C = ElementType!Ret; assert(range.length == 4); assert(buf.length == 4); diff --git a/std/parallelism.d b/std/parallelism.d index d827032c9..94dd0f0f2 100644 --- a/std/parallelism.d +++ b/std/parallelism.d @@ -209,18 +209,18 @@ private template MapType(R, functions...) { static if(functions.length == 0) { - alias typeof(unaryFun!(functions[0])(ElementType!R.init)) MapType; + alias MapType = typeof(unaryFun!(functions[0])(ElementType!R.init)); } else { - alias typeof(adjoin!(staticMap!(unaryFun, functions)) - (ElementType!R.init)) MapType; + alias MapType = typeof(adjoin!(staticMap!(unaryFun, functions)) + (ElementType!R.init)); } } private template ReduceType(alias fun, R, E) { - alias typeof(binaryFun!fun(E.init, ElementType!R.init)) ReduceType; + alias ReduceType = typeof(binaryFun!fun(E.init, ElementType!R.init)); } private template noUnsharedAliasing(T) @@ -242,17 +242,17 @@ private template isSafeTask(F) unittest { - alias void function() @safe F1; - alias void function() F2; - alias void function(uint, string) @trusted F3; - alias void function(uint, char[]) F4; + alias F1 = void function() @safe; + alias F2 = void function(); + alias F3 = void function(uint, string) @trusted; + alias F4 = void function(uint, char[]); static assert( isSafeTask!F1); static assert(!isSafeTask!F2); static assert( isSafeTask!F3); static assert(!isSafeTask!F4); - alias uint[] function(uint, string) pure @trusted F5; + alias F5 = uint[] function(uint, string) pure @trusted; static assert( isSafeTask!F5); } @@ -300,7 +300,7 @@ private enum TaskStatus : ubyte private template AliasReturn(alias fun, T...) { - alias typeof({ T args; return fun(args); }) AliasReturn; + alias AliasReturn = typeof({ T args; return fun(args); }); } // Should be private, but std.algorithm.reduce is used in the zero-thread case @@ -309,13 +309,13 @@ template reduceAdjoin(functions...) { static if(functions.length == 1) { - alias binaryFun!(functions[0]) reduceAdjoin; + alias reduceAdjoin = binaryFun!(functions[0]); } else { T reduceAdjoin(T, U)(T lhs, U rhs) { - alias staticMap!(binaryFun, functions) funs; + alias funs = staticMap!(binaryFun, functions); foreach(i, Unused; typeof(lhs.expand)) { @@ -331,13 +331,13 @@ private template reduceFinish(functions...) { static if(functions.length == 1) { - alias binaryFun!(functions[0]) reduceFinish; + alias reduceFinish = binaryFun!(functions[0]); } else { T reduceFinish(T)(T lhs, T rhs) { - alias staticMap!(binaryFun, functions) funs; + alias funs = staticMap!(binaryFun, functions); foreach(i, Unused; typeof(lhs.expand)) { @@ -474,11 +474,11 @@ struct Task(alias fun, Args...) */ static if(__traits(isSame, fun, run)) { - alias _args[1..$] args; + alias args = _args[1..$]; } else { - alias _args args; + alias args = _args; } @@ -514,7 +514,7 @@ struct Task(alias fun, Args...) The return type of the function called by this $(D Task). This can be $(D void). */ - alias typeof(fun(_args)) ReturnType; + alias ReturnType = typeof(fun(_args)); static if(!is(ReturnType == void)) { @@ -1534,7 +1534,7 @@ public: ParallelForeach!R parallel(R)(R range, size_t workUnitSize) { enforce(workUnitSize > 0, "workUnitSize must be > 0."); - alias ParallelForeach!R RetType; + alias RetType = ParallelForeach!R; return RetType(this, range, workUnitSize); } @@ -1642,14 +1642,14 @@ public: { static if(functions.length == 1) { - alias unaryFun!(functions[0]) fun; + alias fun = unaryFun!(functions[0]); } else { - alias adjoin!(staticMap!(unaryFun, functions)) fun; + alias fun = adjoin!(staticMap!(unaryFun, functions)); } - alias args[0] range; + alias range = args[0]; immutable len = range.length; static if( @@ -1658,9 +1658,9 @@ public: is(MapType!(Args[0], functions) : ElementType!(Args[$ - 1])) ) { - alias args[$ - 1] buf; - alias args[0..$ - 1] args2; - alias Args[0..$ - 1] Args2; + alias buf = args[$ - 1]; + alias args2 = args[0..$ - 1]; + alias Args2 = Args[0..$ - 1]; enforce(buf.length == len, text("Can't use a user supplied buffer that's the wrong ", "size. (Expected :", len, " Got: ", buf.length)); @@ -1672,8 +1672,8 @@ public: else { auto buf = uninitializedArray!(MapType!(Args[0], functions)[])(len); - alias args args2; - alias Args Args2; + alias args2 = args; + alias Args2 = Args; } if(!len) return buf; @@ -1689,7 +1689,7 @@ public: auto workUnitSize = defaultWorkUnitSize(range.length); } - alias typeof(range) R; + alias R = typeof(range); if(workUnitSize > len) { @@ -1823,11 +1823,11 @@ public: "Work unit size must be smaller than buffer size."); static if(functions.length == 1) { - alias unaryFun!(functions[0]) fun; + alias fun = unaryFun!(functions[0]); } else { - alias adjoin!(staticMap!(unaryFun, functions)) fun; + alias fun = adjoin!(staticMap!(unaryFun, functions)); } static final class Map @@ -1841,7 +1841,7 @@ public: is(typeof(source.bufPos)) && is(typeof(source.doBufSwap())); - alias MapType!(S, functions) E; + alias E = MapType!(S, functions); E[] buf1, buf2; S source; TaskPool pool; @@ -1852,7 +1852,7 @@ public: static if(isRandomAccessRange!S) { - alias S FromType; + alias FromType = S; void popSource() { @@ -1885,7 +1885,7 @@ public: ); } - alias typeof(source.buf1) FromType; + alias FromType = typeof(source.buf1); FromType from; // Just swap our input buffer with source's output buffer. @@ -1912,7 +1912,7 @@ public: } else { - alias ElementType!S[] FromType; + alias FromType = ElementType!S[]; // The temporary array that data is copied to before being // mapped. @@ -2138,7 +2138,7 @@ public: // the heap. // The element type of S. - alias ElementType!S E; // Needs to be here b/c of forward ref bugs. + alias E = ElementType!S; // Needs to be here b/c of forward ref bugs. private: E[] buf1, buf2; @@ -2428,19 +2428,19 @@ public: /// auto reduce(Args...)(Args args) { - alias reduceAdjoin!functions fun; - alias reduceFinish!functions finishFun; + alias fun = reduceAdjoin!functions; + alias finishFun = reduceFinish!functions; static if(isIntegral!(Args[$ - 1])) { size_t workUnitSize = cast(size_t) args[$ - 1]; - alias args[0..$ - 1] args2; - alias Args[0..$ - 1] Args2; + alias args2 = args[0..$ - 1]; + alias Args2 = Args[0..$ - 1]; } else { - alias args args2; - alias Args Args2; + alias args2 = args; + alias Args2 = Args; } auto makeStartValue(Type)(Type e) @@ -2466,8 +2466,8 @@ public: static if(args2.length == 2) { static assert(isInputRange!(Args2[1])); - alias args2[1] range; - alias args2[0] seed; + alias range = args2[1]; + alias seed = args2[0]; enum explicitSeed = true; static if(!is(typeof(workUnitSize))) @@ -2478,7 +2478,7 @@ public: else { static assert(args2.length == 1); - alias args2[0] range; + alias range = args2[0]; static if(!is(typeof(workUnitSize))) { @@ -2493,8 +2493,8 @@ public: range.popFront(); } - alias typeof(seed) E; - alias typeof(range) R; + alias E = typeof(seed); + alias R = typeof(range); E reduceOnRange(R range, size_t lowerBound, size_t upperBound) { @@ -2596,7 +2596,7 @@ public: immutable size_t nWorkUnits = (len / workUnitSize) + ((len % workUnitSize == 0) ? 0 : 1); assert(nWorkUnits * workUnitSize >= len); - alias Task!(run, typeof(&reduceOnRange), R, size_t, size_t) RTask; + alias RTask = Task!(run, typeof(&reduceOnRange), R, size_t, size_t); RTask[] tasks; // Can't use alloca() due to Bug 3753. Use a fixed buffer @@ -3366,7 +3366,7 @@ private void submitAndExecute( { immutable nThreads = pool.size + 1; - alias typeof(scopedTask(doIt)) PTask; + alias PTask = typeof(scopedTask(doIt)); import core.stdc.stdlib; import core.stdc.string : memcpy; @@ -3625,7 +3625,7 @@ enum string parallelApplyMixinInputRange = q{ static if(hasLvalueElements!R) { - alias ElementType!R*[] Temp; + alias Temp = ElementType!R*[]; Temp temp; // Returns: The previous value of nPopped. @@ -3655,7 +3655,7 @@ enum string parallelApplyMixinInputRange = q{ else { - alias ElementType!R[] Temp; + alias Temp = ElementType!R[]; Temp temp; // Returns: The previous value of nPopped. @@ -3788,17 +3788,17 @@ private struct ParallelForeach(R) TaskPool pool; R range; size_t workUnitSize; - alias ElementType!R E; + alias E = ElementType!R; static if(hasLvalueElements!R) { - alias int delegate(ref E) NoIndexDg; - alias int delegate(size_t, ref E) IndexDg; + alias NoIndexDg = int delegate(ref E); + alias IndexDg = int delegate(size_t, ref E); } else { - alias int delegate(E) NoIndexDg; - alias int delegate(size_t, E) IndexDg; + alias NoIndexDg = int delegate(E); + alias IndexDg = int delegate(size_t, E); } int opApply(scope NoIndexDg dg) @@ -3837,8 +3837,8 @@ private struct RoundRobinBuffer(C1, C2) { // No need for constraints because they're already checked for in asyncBuf. - alias ParameterTypeTuple!(C1.init)[0] Array; - alias typeof(Array.init[0]) T; + alias Array = ParameterTypeTuple!(C1.init)[0]; + alias T = typeof(Array.init[0]); T[][] bufs; size_t index; diff --git a/std/path.d b/std/path.d index 4e2b15aff..39b8155f3 100644 --- a/std/path.d +++ b/std/path.d @@ -121,7 +121,7 @@ version(Windows) private bool isSeparator(dchar c) @safe pure nothrow { return isDirSeparator(c) || isDriveSeparator(c); } -version(Posix) private alias isDirSeparator isSeparator; +version(Posix) private alias isSeparator = isDirSeparator; /* Helper function that determines the position of the last @@ -1840,7 +1840,7 @@ else version (Windows) bool isAbsolute(C)(in C[] path) @safe pure nothrow return isDriveRoot(path) || isUNC(path); } -else version (Posix) alias isRooted isAbsolute; +else version (Posix) alias isAbsolute = isRooted; unittest diff --git a/std/process.d b/std/process.d index 504139d8f..6e239179e 100644 --- a/std/process.d +++ b/std/process.d @@ -1451,7 +1451,7 @@ Pipe pipe() @trusted //TODO: @safe auto readFD = _open_osfhandle(readHandle, _O_RDONLY); auto writeFD = _open_osfhandle(writeHandle, _O_APPEND); } - version (DMC_RUNTIME) alias .close _close; + version (DMC_RUNTIME) alias _close = .close; if (readFD == -1 || writeFD == -1) { // Close file descriptors, then throw. @@ -3022,8 +3022,8 @@ private void toAStringz(in string[] a, const(char)**az) // Incorporating idea (for spawnvp() on Posix) from Dave Fladebo -alias std.c.process._P_WAIT P_WAIT; -alias std.c.process._P_NOWAIT P_NOWAIT; +alias P_WAIT = std.c.process._P_WAIT; +alias P_NOWAIT = std.c.process._P_NOWAIT; int spawnvp(int mode, string pathname, string[] argv) { @@ -3099,11 +3099,11 @@ Lerror: } // _spawnvp private { - alias WIFSTOPPED stopped; - alias WIFSIGNALED signaled; - alias WTERMSIG termsig; - alias WIFEXITED exited; - alias WEXITSTATUS exitstatus; + alias stopped = WIFSTOPPED; + alias signaled = WIFSIGNALED; + alias termsig = WTERMSIG; + alias exited = WIFEXITED; + alias exitstatus = WEXITSTATUS; } // private } // version (Posix) @@ -3223,7 +3223,7 @@ else * writefln("Current process id: %s", getpid()); * --- */ -alias core.thread.getpid getpid; +alias getpid = core.thread.getpid; /** Runs $(D_PARAM cmd) in a shell and returns its standard output. If diff --git a/std/random.d b/std/random.d index 42673f5ba..a54514a6b 100644 --- a/std/random.d +++ b/std/random.d @@ -449,9 +449,9 @@ rnd0.seed(unpredictableSeed); n = rnd0.front; // different across runs ---- */ -alias LinearCongruentialEngine!(uint, 16807, 0, 2147483647) MinstdRand0; +alias MinstdRand0 = LinearCongruentialEngine!(uint, 16807, 0, 2147483647); /// ditto -alias LinearCongruentialEngine!(uint, 48271, 0, 2147483647) MinstdRand; +alias MinstdRand = LinearCongruentialEngine!(uint, 48271, 0, 2147483647); unittest { @@ -1016,13 +1016,13 @@ struct XorshiftEngine(UIntType, UIntType bits, UIntType a, UIntType b, UIntType * num = rnd.front; // different across runs * ----- */ -alias XorshiftEngine!(uint, 32, 13, 17, 15) Xorshift32; -alias XorshiftEngine!(uint, 64, 10, 13, 10) Xorshift64; /// ditto -alias XorshiftEngine!(uint, 96, 10, 5, 26) Xorshift96; /// ditto -alias XorshiftEngine!(uint, 128, 11, 8, 19) Xorshift128; /// ditto -alias XorshiftEngine!(uint, 160, 2, 1, 4) Xorshift160; /// ditto -alias XorshiftEngine!(uint, 192, 2, 1, 4) Xorshift192; /// ditto -alias Xorshift128 Xorshift; /// ditto +alias Xorshift32 = XorshiftEngine!(uint, 32, 13, 17, 15) ; +alias Xorshift64 = XorshiftEngine!(uint, 64, 10, 13, 10); /// ditto +alias Xorshift96 = XorshiftEngine!(uint, 96, 10, 5, 26); /// ditto +alias Xorshift128 = XorshiftEngine!(uint, 128, 11, 8, 19); /// ditto +alias Xorshift160 = XorshiftEngine!(uint, 160, 2, 1, 4); /// ditto +alias Xorshift192 = XorshiftEngine!(uint, 192, 2, 1, 4); /// ditto +alias Xorshift = Xorshift128; /// ditto unittest @@ -1043,7 +1043,7 @@ unittest [0UL, 246875399, 3690007200, 1264581005, 3906711041, 1866187943, 2481925219, 2464530826, 1604040631, 3653403911] ]; - alias TypeTuple!(Xorshift32, Xorshift64, Xorshift96, Xorshift128, Xorshift160, Xorshift192) XorshiftTypes; + alias XorshiftTypes = TypeTuple!(Xorshift32, Xorshift64, Xorshift96, Xorshift128, Xorshift160, Xorshift192); foreach (I, Type; XorshiftTypes) { @@ -1143,7 +1143,7 @@ nice random numbers, and (2) you don't care for the minutiae of the method being used. */ -alias Mt19937 Random; +alias Random = Mt19937; unittest { @@ -1233,7 +1233,7 @@ auto uniform(string boundaries = "[)", (T1 a, T2 b, ref UniformRandomNumberGenerator urng) if (isFloatingPoint!(CommonType!(T1, T2))) { - alias Unqual!(CommonType!(T1, T2)) NumberType; + alias NumberType = Unqual!(CommonType!(T1, T2)); static if (boundaries[0] == '(') { NumberType _a = nextafter(cast(NumberType) a, NumberType.infinity); diff --git a/std/range.d b/std/range.d index ff1c487de..200f57883 100644 --- a/std/range.d +++ b/std/range.d @@ -442,13 +442,13 @@ enum dummyRanges = q{ return arr.length; } - alias length opDollar; + alias opDollar = length; } } enum dummyLength = 10; - alias TypeTuple!( + alias AllDummyRanges = TypeTuple!( DummyRange!(ReturnBy.Reference, Length.Yes, RangeType.Forward), DummyRange!(ReturnBy.Reference, Length.Yes, RangeType.Bidirectional), DummyRange!(ReturnBy.Reference, Length.Yes, RangeType.Random), @@ -461,7 +461,7 @@ enum dummyRanges = q{ DummyRange!(ReturnBy.Value, Length.No, RangeType.Input), DummyRange!(ReturnBy.Value, Length.No, RangeType.Forward), DummyRange!(ReturnBy.Value, Length.No, RangeType.Bidirectional) - ) AllDummyRanges; + ); }; @@ -1290,7 +1290,7 @@ unittest void popBack(); ref int opIndex(uint); @property size_t length(); - alias length opDollar; + alias opDollar = length; //int opSlice(uint, uint); } static assert(!isRandomAccessRange!(A)); @@ -1321,7 +1321,7 @@ unittest int opIndex(size_t n) const { return 0; } @property size_t length() const { return 0; } - alias length opDollar; + alias opDollar = length; void put(int e){ } } @@ -1387,9 +1387,9 @@ $(D void). template ElementType(R) { static if (is(typeof(R.init.front.init) T)) - alias T ElementType; + alias ElementType = T; else - alias void ElementType; + alias ElementType = void; } /// @@ -1471,9 +1471,9 @@ $(D ElementType). template ElementEncodingType(R) { static if (isNarrowString!R) - alias typeof(*lvalueOf!R.ptr) ElementEncodingType; + alias ElementEncodingType = typeof(*lvalueOf!R.ptr); else - alias ElementType!R ElementEncodingType; + alias ElementEncodingType = ElementType!R; } /// @@ -1912,14 +1912,14 @@ if (isBidirectionalRange!(Unqual!Range)) { static struct Result() { - private alias Unqual!Range R; + private alias R = Unqual!Range; // User code can get and set source, too R source; static if (hasLength!R) { - private alias CommonType!(size_t, typeof(source.length)) IndexType; + private alias IndexType = CommonType!(size_t, typeof(source.length)); IndexType retroIndex(IndexType n) { @@ -1928,7 +1928,7 @@ if (isBidirectionalRange!(Unqual!Range)) } public: - alias R Source; + alias Source = R; @property bool empty() { return source.empty; } @property auto save() @@ -2003,7 +2003,7 @@ if (isBidirectionalRange!(Unqual!Range)) return source.length; } - alias length opDollar; + alias opDollar = length; } } @@ -2137,7 +2137,7 @@ if (isInputRange!(Unqual!Range)) { static struct Result { - private alias Unqual!Range R; + private alias R = Unqual!Range; public R source; private size_t _n; @@ -2321,7 +2321,7 @@ if (isInputRange!(Unqual!Range)) return (source.length + _n - 1) / _n; } - alias length opDollar; + alias opDollar = length; } } return Result(r, n); @@ -2495,8 +2495,8 @@ if (Ranges.length > 0 && static struct Result { private: - alias staticMap!(Unqual, Ranges) R; - alias CommonType!(staticMap!(.ElementType, R)) RvalueElementType; + alias R = staticMap!(Unqual, Ranges); + alias RvalueElementType = CommonType!(staticMap!(.ElementType, R)); private template sameET(A) { enum sameET = is(.ElementType!A == RvalueElementType); @@ -2511,7 +2511,7 @@ if (Ranges.length > 0 && } else { - alias RvalueElementType ElementType; + alias ElementType = RvalueElementType; } static if (allSameType && allSatisfy!(hasLvalueElements, R)) { @@ -2686,7 +2686,7 @@ if (Ranges.length > 0 && return result; } - alias length opDollar; + alias opDollar = length; } static if (allSatisfy!(isRandomAccessRange, R)) @@ -3000,7 +3000,7 @@ if (Rs.length > 1 && allSatisfy!(isInputRange, staticMap!(Unqual, Rs))) return result; } - alias length opDollar; + alias opDollar = length; } } @@ -3100,14 +3100,14 @@ if (isInputRange!(Unqual!Range) && //take for slicing infinite ranges. !((!isInfinite!(Unqual!Range) && hasSlicing!(Unqual!Range)) || is(Range T == Take!T))) { - private alias Unqual!Range R; + private alias R = Unqual!Range; // User accessible in read and write public R source; private size_t _maxAvailable; - alias R Source; + alias Source = R; @property bool empty() { @@ -3165,7 +3165,7 @@ if (isInputRange!(Unqual!Range) && return _maxAvailable; } - alias length opDollar; + alias opDollar = length; } else static if (hasLength!R) { @@ -3174,7 +3174,7 @@ if (isInputRange!(Unqual!Range) && return min(_maxAvailable, source.length); } - alias length opDollar; + alias opDollar = length; } static if (isRandomAccessRange!R) @@ -3256,7 +3256,7 @@ template Take(R) if (isInputRange!(Unqual!R) && ((!isInfinite!(Unqual!R) && hasSlicing!(Unqual!R)) || is(R T == Take!T))) { - alias R Take; + alias Take = R; } // take for finite ranges with slicing @@ -3321,7 +3321,7 @@ unittest foreach(DummyType; AllDummyRanges) { DummyType dummy; auto t = take(dummy, 5); - alias typeof(t) T; + alias T = typeof(t); static if (isRandomAccessRange!DummyType) { static assert(isRandomAccessRange!T); @@ -3423,7 +3423,7 @@ if (isInputRange!R) } void popFront() { _input.popFront(); --_n; } @property size_t length() const { return _n; } - alias length opDollar; + alias opDollar = length; static if (isForwardRange!R) @property auto save() @@ -3578,7 +3578,7 @@ auto takeOne(R)(R source) if (isInputRange!R) @property auto save() { return Result(_source.save, empty); } @property auto ref back() { assert(!empty); return _source.front; } @property size_t length() const { return !empty; } - alias length opDollar; + alias opDollar = length; auto ref opIndex(size_t n) { assert(n < length); return _source.front; } auto opSlice(size_t m, size_t n) { @@ -4589,7 +4589,7 @@ unittest //10845 assert(equal(cycle(a).take(10), [0, 1, 2, 0, 1, 2, 0, 1, 2, 0])); } -private template lengthType(R) { alias typeof((inout int = 0){ R r = void; return r.length; }()) lengthType; } +private alias lengthType(R) = typeof((inout int = 0){ R r = void; return r.length; }()); /** Iterate several ranges in lockstep. The element type is a proxy tuple @@ -4619,7 +4619,7 @@ struct Zip(Ranges...) { alias R = Ranges; R ranges; - alias Tuple!(staticMap!(.ElementType, R)) ElementType; + alias ElementType = Tuple!(staticMap!(.ElementType, R)); StoppingPolicy stoppingPolicy = StoppingPolicy.shortest; /** @@ -4926,7 +4926,7 @@ struct Zip(Ranges...) return result; } - alias length opDollar; + alias opDollar = length; } /** @@ -5085,7 +5085,7 @@ unittest auto stuff = tuple(tuple(a1, a2), tuple(filter!"a"(a1), filter!"a"(a2))); - alias Zip!(immutable(int)[], immutable(float)[]) FOO; + alias FOO = Zip!(immutable(int)[], immutable(float)[]); foreach(t; stuff.expand) { auto arr1 = t[0]; @@ -5294,7 +5294,7 @@ private: // single range. template Lockstep(Range) { - alias Range Lockstep; + alias Lockstep = Range; } /// Ditto @@ -5525,8 +5525,8 @@ struct Sequence(alias fun, State) private: import std.functional : binaryFun; - alias binaryFun!(fun, "a", "n") compute; - alias typeof(compute(State.init, cast(size_t) 1)) ElementType; + alias compute = binaryFun!(fun, "a", "n"); + alias ElementType = typeof(compute(State.init, cast(size_t) 1)); State _state; size_t _n; ElementType _cache; @@ -5660,9 +5660,9 @@ if ((isIntegral!(CommonType!(B, E)) || isPointer!(CommonType!(B, E))) { import std.conv : unsigned; - alias CommonType!(Unqual!B, Unqual!E) Value; - alias Unqual!S StepType; - alias typeof(unsigned((end - begin) / step)) IndexType; + alias Value = CommonType!(Unqual!B, Unqual!E); + alias StepType = Unqual!S; + alias IndexType = typeof(unsigned((end - begin) / step)); static struct Result { @@ -5737,7 +5737,7 @@ if ((isIntegral!(CommonType!(B, E)) || isPointer!(CommonType!(B, E))) } } - alias length opDollar; + alias opDollar = length; } return Result(begin, end, step); @@ -5756,8 +5756,8 @@ if (isIntegral!(CommonType!(B, E)) || isPointer!(CommonType!(B, E))) { import std.conv : unsigned; - alias CommonType!(Unqual!B, Unqual!E) Value; - alias typeof(unsigned(end - begin)) IndexType; + alias Value = CommonType!(Unqual!B, Unqual!E); + alias IndexType = typeof(unsigned(end - begin)); static struct Result { @@ -5807,7 +5807,7 @@ if (isIntegral!(CommonType!(B, E)) || isPointer!(CommonType!(B, E))) return unsigned(pastLast - current); } - alias length opDollar; + alias opDollar = length; } return Result(begin, end); @@ -5824,7 +5824,7 @@ auto iota(E)(E end) auto iota(B, E, S)(B begin, E end, S step) if (isFloatingPoint!(CommonType!(B, E, S))) { - alias Unqual!(CommonType!(B, E, S)) Value; + alias Value = Unqual!(CommonType!(B, E, S)); static struct Result { private Value start, step; @@ -5897,7 +5897,7 @@ if (isFloatingPoint!(CommonType!(B, E, S))) return count - index; } - alias length opDollar; + alias opDollar = length; } return Result(begin, end, step); @@ -6123,9 +6123,9 @@ enum TransverseOptions struct FrontTransversal(Ror, TransverseOptions opt = TransverseOptions.assumeJagged) { - alias Unqual!(Ror) RangeOfRanges; - alias .ElementType!RangeOfRanges RangeType; - alias .ElementType!RangeType ElementType; + alias RangeOfRanges = Unqual!(Ror); + alias RangeType = .ElementType!RangeOfRanges; + alias ElementType = .ElementType!RangeType; private void prime() { @@ -6401,9 +6401,9 @@ unittest { struct Transversal(Ror, TransverseOptions opt = TransverseOptions.assumeJagged) { - private alias Unqual!Ror RangeOfRanges; - private alias ElementType!RangeOfRanges InnerRange; - private alias ElementType!InnerRange E; + private alias RangeOfRanges = Unqual!Ror; + private alias InnerRange = ElementType!RangeOfRanges; + private alias E = ElementType!InnerRange; private void prime() { @@ -6584,7 +6584,7 @@ struct Transversal(Ror, return _input.length; } - alias length opDollar; + alias opDollar = length; } /** @@ -6665,7 +6665,7 @@ unittest } // Test w/o ref return. - alias DummyRange!(ReturnBy.Value, Length.Yes, RangeType.Random) D; + alias D = DummyRange!(ReturnBy.Value, Length.Yes, RangeType.Random); auto drs = [D.init, D.init]; foreach(num; 0..10) { auto t = transversal!(TransverseOptions.enforceNotJagged)(drs, num); @@ -6684,7 +6684,7 @@ unittest struct Transposed(RangeOfRanges) { - //alias typeof(map!"a.front"(RangeOfRanges.init)) ElementType; + //alias ElementType = typeof(map!"a.front"(RangeOfRanges.init)); this(RangeOfRanges input) { @@ -6873,7 +6873,7 @@ struct Indexed(Source, Indices) return _indices.length; } - alias length opDollar; + alias opDollar = length; } static if(isRandomAccessRange!Indices) @@ -7559,7 +7559,7 @@ unittest b.popBack(); assert(b.empty && b.length == 0 && b[].empty); - alias typeof(a) A; + alias A = typeof(a); static assert(isInputRange!A); static assert(isForwardRange!A); static assert(isBidirectionalRange!A); @@ -7901,7 +7901,7 @@ interface RandomAccessFinite(E) : BidirectionalRange!(E) { @property size_t length(); /// - alias length opDollar; + alias opDollar = length; // Can't support slicing until issues with requiring slicing for all // finite random access ranges are fully resolved. @@ -7994,33 +7994,33 @@ class OutputRangeObject(R, E...) : staticMap!(OutputRange, E) { /**Returns the interface type that best matches $(D R).*/ template MostDerivedInputRange(R) if (isInputRange!(Unqual!R)) { - private alias ElementType!R E; + private alias E = ElementType!R; static if (isRandomAccessRange!R) { static if (isInfinite!R) { - alias RandomAccessInfinite!E MostDerivedInputRange; + alias MostDerivedInputRange = RandomAccessInfinite!E; } else static if (hasAssignableElements!R) { - alias RandomFiniteAssignable!E MostDerivedInputRange; + alias MostDerivedInputRange = RandomFiniteAssignable!E; } else { - alias RandomAccessFinite!E MostDerivedInputRange; + alias MostDerivedInputRange = RandomAccessFinite!E; } } else static if (isBidirectionalRange!R) { static if (hasAssignableElements!R) { - alias BidirectionalAssignable!E MostDerivedInputRange; + alias MostDerivedInputRange = BidirectionalAssignable!E; } else { - alias BidirectionalRange!E MostDerivedInputRange; + alias MostDerivedInputRange = BidirectionalRange!E; } } else static if (isForwardRange!R) { static if (hasAssignableElements!R) { - alias ForwardAssignable!E MostDerivedInputRange; + alias MostDerivedInputRange = ForwardAssignable!E; } else { - alias ForwardRange!E MostDerivedInputRange; + alias MostDerivedInputRange = ForwardRange!E; } } else { static if (hasAssignableElements!R) { - alias InputAssignable!E MostDerivedInputRange; + alias MostDerivedInputRange = InputAssignable!E; } else { - alias InputRange!E MostDerivedInputRange; + alias MostDerivedInputRange = InputRange!E; } } } @@ -8031,15 +8031,15 @@ template MostDerivedInputRange(R) if (isInputRange!(Unqual!R)) { */ template InputRangeObject(R) if (isInputRange!(Unqual!R)) { static if (is(R : InputRange!(ElementType!R))) { - alias R InputRangeObject; + alias InputRangeObject = R; } else static if (!is(Unqual!R == R)) { - alias InputRangeObject!(Unqual!R) InputRangeObject; + alias InputRangeObject = InputRangeObject!(Unqual!R); } else { /// class InputRangeObject : MostDerivedInputRange!(R) { private R _range; - private alias ElementType!R E; + private alias E = ElementType!R; this(R range) { this._range = range; @@ -8102,7 +8102,7 @@ template InputRangeObject(R) if (isInputRange!(Unqual!R)) { return _range.length; } - alias length opDollar; + alias opDollar = length; // Can't support slicing until all the issues with // requiring slicing support for finite random access @@ -8338,7 +8338,7 @@ if (isRandomAccessRange!Range && hasLength!Range) { private import std.functional : binaryFun; - private alias binaryFun!pred predFun; + private alias predFun = binaryFun!pred; private bool geq(L, R)(L lhs, R rhs) { return !predFun(lhs, rhs); @@ -8434,7 +8434,7 @@ if (isRandomAccessRange!Range && hasLength!Range) return _input.length; } - alias length opDollar; + alias opDollar = length; /** Releases the controlled range and returns it. @@ -9165,7 +9165,7 @@ assert(buffer2 == [11, 12, 13, 14, 15]); private static string _genSave() @safe pure nothrow { return `import std.conv;` ~ - `alias typeof((*_range).save) S;` ~ + `alias S = typeof((*_range).save);` ~ `static assert(isForwardRange!S, S.stringof ~ " is not a forward range.");` ~ `auto mem = new void[S.sizeof];` ~ `emplace!S(mem, cast(S)(*_range).save);` ~ @@ -9325,7 +9325,7 @@ assert(buffer2 == [11, 12, 13, 14, 15]); private static string _genOpSlice() @safe pure nothrow { return `import std.conv;` ~ - `alias typeof((*_range)[begin .. end]) S;` ~ + `alias S = typeof((*_range)[begin .. end]);` ~ `static assert(hasSlicing!S, S.stringof ~ " is not sliceable.");` ~ `auto mem = new void[S.sizeof];` ~ `emplace!S(mem, cast(S)(*_range)[begin .. end]);` ~ diff --git a/std/regex.d b/std/regex.d index 6cabf3d31..310004182 100644 --- a/std/regex.d +++ b/std/regex.d @@ -3886,7 +3886,7 @@ template BacktrackingMatcher(bool CTregex) //generate code for TypeTuple(S, S+1, S+2, ... E) @system string ctGenSeq(int S, int E) { - string s = "alias TypeTuple!("; + string s = "alias Sequence = TypeTuple!("; if(S < E) s ~= to!string(S); for(int i = S+1; i < E;i++) @@ -3894,7 +3894,7 @@ template BacktrackingMatcher(bool CTregex) s ~= ", "; s ~= to!string(i); } - return s ~") Sequence;"; + return s ~");"; } //alias to TypeTuple(S, S+1, S+2, ... E) @@ -5364,7 +5364,7 @@ enum OneShot { Fwd, Bwd }; { writefln("---------------single shot match ----------------- "); } - alias eval evalFn; + alias evalFn = eval; assert(clist == (ThreadList!DataIndex).init || startPc == RestartPc); // incorrect after a partial match assert(nlist == (ThreadList!DataIndex).init || startPc == RestartPc); startPc = startPc; diff --git a/std/signals.d b/std/signals.d index 052d2a091..59cf54276 100644 --- a/std/signals.d +++ b/std/signals.d @@ -71,7 +71,7 @@ import core.exception : onOutOfMemoryError; extern (C) Object _d_toObject(void* p); // Used in place of Object.notifyRegister and Object.notifyUnRegister. -alias void delegate(Object) DisposeEvt; +alias DisposeEvt = void delegate(Object); extern (C) void rt_attachDisposeEvent( Object obj, DisposeEvt evt ); extern (C) void rt_detachDisposeEvent( Object obj, DisposeEvt evt ); //debug=signal; @@ -151,7 +151,7 @@ mixin template Signal(T1...) * Delegates to struct instances or nested functions must not be * used as slots. */ - alias void delegate(T1) slot_t; + alias slot_t = void delegate(T1); /*** * Call each of the connected slots, passing the argument(s) i to them. diff --git a/std/socket.d b/std/socket.d index 44eeb4982..3d45f936d 100644 --- a/std/socket.d +++ b/std/socket.d @@ -58,8 +58,8 @@ version(Windows) pragma (lib, "wsock32.lib"); private import std.c.windows.windows, std.c.windows.winsock, std.windows.syserror; - private alias std.c.windows.winsock.timeval _ctimeval; - private alias std.c.windows.winsock.linger _clinger; + private alias _ctimeval = std.c.windows.winsock.timeval; + private alias _clinger = std.c.windows.winsock.linger; enum socket_t : SOCKET { INVALID_SOCKET } private const int _SOCKET_ERROR = SOCKET_ERROR; @@ -103,8 +103,8 @@ else version(Posix) private import core.sys.posix.sys.time; //private import core.sys.posix.sys.select; private import core.sys.posix.sys.socket; - private alias core.sys.posix.sys.time.timeval _ctimeval; - private alias core.sys.posix.sys.socket.linger _clinger; + private alias _ctimeval = core.sys.posix.sys.time.timeval; + private alias _clinger = core.sys.posix.sys.socket.linger; private import core.stdc.errno; @@ -739,7 +739,7 @@ class InternetHost } version(Windows) - alias getHostNoSync getHost; + alias getHost = getHostNoSync; else { // posix systems use global state for return value, so we @@ -2003,8 +2003,8 @@ private mixin template FieldProxy(string target, string field) struct TimeVal { _ctimeval ctimeval; - alias typeof(ctimeval.tv_sec) tv_sec_t; - alias typeof(ctimeval.tv_usec) tv_usec_t; + alias tv_sec_t = typeof(ctimeval.tv_sec); + alias tv_usec_t = typeof(ctimeval.tv_usec); version (StdDdoc) // no DDoc for string mixins, can't forward individual fields { @@ -2389,8 +2389,8 @@ struct Linger version (StdDdoc) // no DDoc for string mixins, can't forward individual fields { - private alias typeof(_clinger.init.l_onoff ) l_onoff_t; - private alias typeof(_clinger.init.l_linger) l_linger_t; + private alias l_onoff_t = typeof(_clinger.init.l_onoff ); + private alias l_linger_t = typeof(_clinger.init.l_linger); l_onoff_t on; /// Nonzero for _on. l_linger_t time; /// Linger _time. } diff --git a/std/stdio.d b/std/stdio.d index a3d343191..f1ce8185b 100644 --- a/std/stdio.d +++ b/std/stdio.d @@ -43,7 +43,7 @@ version (Posix) { import core.sys.posix.fcntl; import core.sys.posix.stdio; - alias core.sys.posix.stdio.fileno fileno; + alias fileno = core.sys.posix.stdio.fileno; } version (linux) @@ -89,19 +89,19 @@ version (DIGITAL_MARS_STDIO) int setmode(int, int); } - alias _fputc_nlock FPUTC; - alias _fputwc_nlock FPUTWC; - alias _fgetc_nlock FGETC; - alias _fgetwc_nlock FGETWC; + alias FPUTC = _fputc_nlock; + alias FPUTWC = _fputwc_nlock; + alias FGETC = _fgetc_nlock; + alias FGETWC = _fgetwc_nlock; - alias __fp_lock FLOCK; - alias __fp_unlock FUNLOCK; + alias FLOCK = __fp_lock; + alias FUNLOCK = __fp_unlock; - alias setmode _setmode; + alias _setmode = setmode; enum _O_BINARY = 0x8000; int _fileno(FILE* f) { return f._file; } - alias _fileno fileno; - alias _fdToHandle _get_osfhandle; + alias fileno = _fileno; + alias _get_osfhandle = _fdToHandle; } else version (MICROSOFT_STDIO) { @@ -119,13 +119,13 @@ else version (MICROSOFT_STDIO) int _setmode(int, int); int _fileno(FILE*); } - alias _fputc_nolock FPUTC; - alias _fputwc_nolock FPUTWC; - alias _fgetc_nolock FGETC; - alias _fgetwc_nolock FGETWC; + alias FPUTC = _fputc_nolock; + alias FPUTWC = _fputwc_nolock; + alias FGETC = _fgetc_nolock; + alias FGETWC = _fgetwc_nolock; - alias _lock_file FLOCK; - alias _unlock_file FUNLOCK; + alias FLOCK = _lock_file; + alias FUNLOCK = _unlock_file; enum _O_BINARY = 0x8000; @@ -151,13 +151,13 @@ else version (GCC_IO) size_t size, size_t n, _iobuf *stream); } - alias fputc_unlocked FPUTC; - alias fputwc_unlocked FPUTWC; - alias fgetc_unlocked FGETC; - alias fgetwc_unlocked FGETWC; + alias FPUTC = fputc_unlocked; + alias FPUTWC = fputwc_unlocked; + alias FGETC = fgetc_unlocked; + alias FGETWC = fgetwc_unlocked; - alias flockfile FLOCK; - alias funlockfile FUNLOCK; + alias FLOCK = flockfile; + alias FUNLOCK = funlockfile; } else version (GENERIC_IO) { @@ -175,13 +175,13 @@ else version (GENERIC_IO) int fgetc_unlocked(_iobuf* fp) { return fgetc(cast(shared) fp); } int fgetwc_unlocked(_iobuf* fp) { return fgetwc(cast(shared) fp); } - alias fputc_unlocked FPUTC; - alias fputwc_unlocked FPUTWC; - alias fgetc_unlocked FGETC; - alias fgetwc_unlocked FGETWC; + alias FPUTC = fputc_unlocked; + alias FPUTWC = fputwc_unlocked; + alias FGETC = fgetc_unlocked; + alias FGETWC = fgetwc_unlocked; - alias flockfile FLOCK; - alias funlockfile FUNLOCK; + alias FLOCK = flockfile; + alias FUNLOCK = funlockfile; } else { @@ -1026,7 +1026,7 @@ Throws: $(D Exception) if the file is not opened. auto w = lockingTextWriter(); foreach (arg; args) { - alias typeof(arg) A; + alias A = typeof(arg); static if (isAggregateType!A || is(A == enum)) { import std.format : formattedWrite; @@ -1928,7 +1928,7 @@ $(D Range) that locks the file and allows fast writing to it. { import std.exception : errnoEnforce; - alias ElementEncodingType!A C; + alias C = ElementEncodingType!A; static assert(!is(C == void)); if (writeme[0].sizeof == 1 && orientation <= 0) { @@ -2271,7 +2271,7 @@ unittest * $(RED Scheduled for deprecation in January 2013. * Please use $(D isFileHandle) instead.) */ -alias isFileHandle isStreamingDevice; +alias isStreamingDevice = isFileHandle; /*********************************** For each argument $(D arg) in $(D args), format the argument (as per @@ -2818,18 +2818,18 @@ struct lines // if (fileName.length && fclose(f)) // StdioException("Could not close file `"~fileName~"'"); // } - alias ParameterTypeTuple!(dg) Parms; + alias Parms = ParameterTypeTuple!(dg); static if (isSomeString!(Parms[$ - 1])) { enum bool duplicate = is(Parms[$ - 1] == string) || is(Parms[$ - 1] == wstring) || is(Parms[$ - 1] == dstring); int result = 0; static if (is(Parms[$ - 1] : const(char)[])) - alias char C; + alias C = char; else static if (is(Parms[$ - 1] : const(wchar)[])) - alias wchar C; + alias C = wchar; else static if (is(Parms[$ - 1] : const(dchar)[])) - alias dchar C; + alias C = dchar; C[] line; static if (Parms.length == 2) Parms[0] i = 0; @@ -2864,7 +2864,7 @@ struct lines import std.exception : assumeUnique; import std.conv : to; - alias ParameterTypeTuple!(dg) Parms; + alias Parms = ParameterTypeTuple!(dg); enum duplicate = is(Parms[$ - 1] : immutable(ubyte)[]); int result = 1; int c = void; @@ -2881,7 +2881,7 @@ struct lines static if (duplicate) auto arg = assumeUnique(buffer); else - alias buffer arg; + alias arg = buffer; // unlock the file while calling the delegate FUNLOCK(f._p.handle); scope(exit) FLOCK(f._p.handle); @@ -2916,9 +2916,9 @@ unittest auto deleteme = testFilename(); scope(exit) { std.file.remove(deleteme); } - alias TypeTuple!(string, wstring, dstring, - char[], wchar[], dchar[]) - TestedWith; + alias TestedWith = + TypeTuple!(string, wstring, dstring, + char[], wchar[], dchar[]); foreach (T; TestedWith) { // test looping with an empty file std.file.write(deleteme, ""); @@ -2960,8 +2960,8 @@ unittest // test with ubyte[] inputs //@@@BUG 2612@@@ - //alias TypeTuple!(immutable(ubyte)[], ubyte[]) TestedWith2; - alias TypeTuple!(immutable(ubyte)[], ubyte[]) TestedWith2; + //alias TestedWith2 = TypeTuple!(immutable(ubyte)[], ubyte[]); + alias TestedWith2 = TypeTuple!(immutable(ubyte)[], ubyte[]); foreach (T; TestedWith2) { // test looping with an empty file std.file.write(deleteme, ""); diff --git a/std/stream.d b/std/stream.d index 674ecd1c7..c751a7f97 100644 --- a/std/stream.d +++ b/std/stream.d @@ -1726,7 +1726,7 @@ class BufferedStream : FilterStream { else return TreadLine!(char).readLine(inBuffer); } - alias Stream.readLine readLine; + alias readLine = Stream.readLine; override wchar[] readLineW(wchar[] inBuffer) { if (ungetAvailable()) @@ -1734,7 +1734,7 @@ class BufferedStream : FilterStream { else return TreadLine!(wchar).readLine(inBuffer); } - alias Stream.readLineW readLineW; + alias readLineW = Stream.readLineW; override void flush() out { @@ -1824,7 +1824,7 @@ version (Windows) { version (Posix) { private import core.sys.posix.fcntl; private import core.sys.posix.unistd; - alias int HANDLE; + alias HANDLE = int; } /// This subclass is for unbuffered file system streams. diff --git a/std/string.d b/std/string.d index 977153191..c34efa7ba 100644 --- a/std/string.d +++ b/std/string.d @@ -937,7 +937,7 @@ auto representation(Char)(Char[] s) pure nothrow if (isSomeChar!Char) { // Get representation type - alias TypeTuple!(ubyte, ushort, uint)[Char.sizeof / 2] U; + alias U = TypeTuple!(ubyte, ushort, uint)[Char.sizeof / 2]; // const and immutable storage classes static if (is(Char == immutable)) @@ -1731,7 +1731,7 @@ S detab(S)(S s, size_t tabSize = 8) @trusted pure if (isSomeString!S) { assert(tabSize > 0); - alias Unqual!(typeof(s[0])) C; + alias C = Unqual!(typeof(s[0])); bool changes = false; C[] result; int column; @@ -1817,7 +1817,7 @@ S entab(S)(S s, size_t tabSize = 8) @trusted pure if (isSomeString!S) { bool changes = false; - alias Unqual!(typeof(s[0])) C; + alias C = Unqual!(typeof(s[0])); C[] result; int nspaces = 0; @@ -2511,7 +2511,7 @@ unittest } // Explicitly undocumented. It will be removed in July 2014. -deprecated("Please use std.string.format instead.") alias format xformat; +deprecated("Please use std.string.format instead.") alias xformat = format; deprecated unittest { @@ -2534,7 +2534,7 @@ deprecated unittest } // Explicitly undocumented. It will be removed in July 2014. -deprecated("Please use std.string.sformat instead.") alias sformat xsformat; +deprecated("Please use std.string.sformat instead.") alias xsformat = sformat; deprecated unittest { diff --git a/std/traits.d b/std/traits.d index 751cdbd6d..b8bd625b1 100644 --- a/std/traits.d +++ b/std/traits.d @@ -225,14 +225,14 @@ private return Demangle!uint(atts, mstr); } - alias TypeTuple!(byte, ubyte, short, ushort, int, uint, long, ulong) IntegralTypeList; - alias TypeTuple!(byte, short, int, long) SignedIntTypeList; - alias TypeTuple!(ubyte, ushort, uint, ulong) UnsignedIntTypeList; - alias TypeTuple!(float, double, real) FloatingPointTypeList; - alias TypeTuple!(ifloat, idouble, ireal) ImaginaryTypeList; - alias TypeTuple!(cfloat, cdouble, creal) ComplexTypeList; - alias TypeTuple!(IntegralTypeList, FloatingPointTypeList) NumericTypeList; - alias TypeTuple!(char, wchar, dchar) CharTypeList; + alias IntegralTypeList = TypeTuple!(byte, ubyte, short, ushort, int, uint, long, ulong); + alias SignedIntTypeList = TypeTuple!(byte, short, int, long); + alias UnsignedIntTypeList = TypeTuple!(ubyte, ushort, uint, ulong); + alias FloatingPointTypeList = TypeTuple!(float, double, real); + alias ImaginaryTypeList = TypeTuple!(ifloat, idouble, ireal); + alias ComplexTypeList = TypeTuple!(cfloat, cdouble, creal); + alias NumericTypeList = TypeTuple!(IntegralTypeList, FloatingPointTypeList); + alias CharTypeList = TypeTuple!(char, wchar, dchar); } package { @@ -291,7 +291,7 @@ package version(unittest) { - alias TypeTuple!(MutableOf, ConstOf, SharedOf, SharedConstOf, ImmutableOf) TypeQualifierList; + alias TypeQualifierList = TypeTuple!(MutableOf, ConstOf, SharedOf, SharedConstOf, ImmutableOf); struct SubTypeOf(T) { @@ -374,7 +374,7 @@ template moduleName(alias T) enum moduleName = packagePrefix ~ T.stringof[7..$]; } else - alias moduleName!(__traits(parent, T)) moduleName; + alias moduleName = moduleName!(__traits(parent, T)); // If you use enum, it will cause compiler ICE } unittest @@ -504,12 +504,12 @@ private template fullyQualifiedNameImplForTypes(T, _inout = 3 } - alias TypeTuple!(is(T == const), is(T == immutable), is(T == shared), is(T == inout)) qualifiers; - alias TypeTuple!(false, false, false, false) noQualifiers; + alias qualifiers = TypeTuple!(is(T == const), is(T == immutable), is(T == shared), is(T == inout)); + alias noQualifiers = TypeTuple!(false, false, false, false); string storageClassesString(uint psc)() @property { - alias ParameterStorageClass PSC; + alias PSC = ParameterStorageClass; return format("%s%s%s%s", psc & PSC.scope_ ? "scope " : "", @@ -523,8 +523,8 @@ private template fullyQualifiedNameImplForTypes(T, { import std.array, std.algorithm, std.range; - alias ParameterTypeTuple!(T) parameters; - alias ParameterStorageClassTuple!(T) parameterStC; + alias parameters = ParameterTypeTuple!(T); + alias parameterStC = ParameterStorageClassTuple!(T); enum variadic = variadicFunctionStyle!T; static if (variadic == Variadic.no) @@ -566,7 +566,7 @@ private template fullyQualifiedNameImplForTypes(T, string functionAttributeString(T)() @property { - alias FunctionAttribute FA; + alias FA = FunctionAttribute; enum attrs = functionAttributes!T; static if (attrs == FA.none) @@ -700,7 +700,7 @@ unittest static assert(fullyQualifiedName!Ambiguous == fullyQualifiedNameImplForTypes!(Ambiguous, false, false, false, false)); // Main tests - alias fullyQualifiedName fqn; + alias fqn = fullyQualifiedName; enum inner_name = "std.traits.QualifiedNameTests.Inner"; with (QualifiedNameTests) { @@ -763,7 +763,7 @@ template ReturnType(func...) if (func.length == 1 && isCallable!func) { static if (is(FunctionTypeOf!func R == return)) - alias R ReturnType; + alias ReturnType = R; else static assert(0, "argument has no return type"); } @@ -775,14 +775,14 @@ unittest int opCall (int i) { return 1;} } - alias ReturnType!G ShouldBeInt; + alias ShouldBeInt = ReturnType!G; static assert(is(ShouldBeInt == int)); G g; static assert(is(ReturnType!g == int)); G* p; - alias ReturnType!p pg; + alias pg = ReturnType!p; static assert(is(pg == int)); class C @@ -799,10 +799,10 @@ unittest { int prop() @property { return 0; } } - alias ReturnType!(Test.prop) R_Test_prop; + alias R_Test_prop = ReturnType!(Test.prop); static assert(is(R_Test_prop == int)); - alias ReturnType!((int a) { return a; }) R_dglit; + alias R_dglit = ReturnType!((int a) { return a; }); static assert(is(R_dglit == int)); } @@ -823,7 +823,7 @@ template ParameterTypeTuple(func...) if (func.length == 1 && isCallable!func) { static if (is(FunctionTypeOf!func P == function)) - alias P ParameterTypeTuple; + alias ParameterTypeTuple = P; else static assert(0, "argument has no parameters"); } @@ -844,10 +844,10 @@ unittest { int prop() @property { return 0; } } - alias ParameterTypeTuple!(Test.prop) P_Test_prop; + alias P_Test_prop = ParameterTypeTuple!(Test.prop); static assert(P_Test_prop.length == 0); - alias ParameterTypeTuple!((int a){}) P_dglit; + alias P_dglit = ParameterTypeTuple!((int a){}); static assert(P_dglit.length == 1); static assert(is(P_dglit[0] == int)); } @@ -885,12 +885,12 @@ function $(D func). Example: -------------------- -alias ParameterStorageClass STC; // shorten the enum name +alias STC = ParameterStorageClass; // shorten the enum name void func(ref int ctx, out real result, real param) { } -alias ParameterStorageClassTuple!func pstc; +alias pstc = ParameterStorageClassTuple!func; static assert(pstc.length == 3); // three parameters static assert(pstc[0] == STC.ref_); static assert(pstc[1] == STC.out_); @@ -914,13 +914,13 @@ enum ParameterStorageClass : uint template ParameterStorageClassTuple(func...) if (func.length == 1 && isCallable!func) { - alias Unqual!(FunctionTypeOf!func) Func; + alias Func = Unqual!(FunctionTypeOf!func); /* * TypeFuncion: * CallConvention FuncAttrs Arguments ArgClose Type */ - alias ParameterTypeTuple!Func Params; + alias Params = ParameterTypeTuple!Func; // chop off CallConvention and FuncAttrs enum margs = demangleFunctionAttributes(mangledName!Func[1 .. $]).rest; @@ -934,29 +934,30 @@ template ParameterStorageClassTuple(func...) enum skip = mangledName!(Params[i]).length; // for bypassing Type enum rest = demang.rest; - alias TypeTuple!( + alias demangleNextParameter = + TypeTuple!( demang.value + 0, // workaround: "not evaluatable at ..." demangleNextParameter!(rest[skip .. $], i + 1) - ) demangleNextParameter; + ); } else // went thru all the parameters { - alias TypeTuple!() demangleNextParameter; + alias demangleNextParameter = TypeTuple!(); } } - alias demangleNextParameter!margs ParameterStorageClassTuple; + alias ParameterStorageClassTuple = demangleNextParameter!margs; } unittest { - alias ParameterStorageClass STC; + alias STC = ParameterStorageClass; void noparam() {} static assert(ParameterStorageClassTuple!noparam.length == 0); void test(scope int, ref int, out int, lazy int, int) { } - alias ParameterStorageClassTuple!test test_pstc; + alias test_pstc = ParameterStorageClassTuple!test; static assert(test_pstc.length == 5); static assert(test_pstc[0] == STC.scope_); static assert(test_pstc[1] == STC.ref_); @@ -971,15 +972,15 @@ unittest } Test testi; - alias ParameterStorageClassTuple!(Test.test_const) test_const_pstc; + alias test_const_pstc = ParameterStorageClassTuple!(Test.test_const); static assert(test_const_pstc.length == 1); static assert(test_const_pstc[0] == STC.none); - alias ParameterStorageClassTuple!(testi.test_sharedconst) test_sharedconst_pstc; + alias test_sharedconst_pstc = ParameterStorageClassTuple!(testi.test_sharedconst); static assert(test_sharedconst_pstc.length == 1); static assert(test_sharedconst_pstc[0] == STC.none); - alias ParameterStorageClassTuple!((ref int a) {}) dglit_pstc; + alias dglit_pstc = ParameterStorageClassTuple!((ref int a) {}); static assert(dglit_pstc.length == 1); static assert(dglit_pstc[0] == STC.ref_); @@ -1015,18 +1016,18 @@ template ParameterIdentifierTuple(func...) // Define dummy entities to avoid pointless errors template Get(size_t i) { enum Get = ""; } - alias TypeTuple!() PT; + alias PT = TypeTuple!(); } template Impl(size_t i = 0) { static if (i == PT.length) - alias TypeTuple!() Impl; + alias Impl = TypeTuple!(); else - alias TypeTuple!(Get!i, Impl!(i+1)) Impl; + alias Impl = TypeTuple!(Get!i, Impl!(i+1)); } - alias Impl!() ParameterIdentifierTuple; + alias ParameterIdentifierTuple = Impl!(); } /// @@ -1036,9 +1037,10 @@ unittest int foo(int num, string name); static assert([ParameterIdentifierTuple!foo] == ["num", "name"]); } + unittest { - alias ParameterIdentifierTuple PIT; + alias PIT = ParameterIdentifierTuple; void bar(int num, string name, int[] array){} static assert([PIT!bar] == ["num", "name", "array"]); @@ -1088,7 +1090,7 @@ template ParameterDefaultValueTuple(func...) static if (is(typeof(get()))) enum Get = get(); else - alias void Get; + alias Get = void; // If default arg doesn't exist, returns void instead. } } @@ -1105,18 +1107,18 @@ template ParameterDefaultValueTuple(func...) // Define dummy entities to avoid pointless errors template Get(size_t i) { enum Get = ""; } - alias TypeTuple!() PT; + alias PT = TypeTuple!(); } template Impl(size_t i = 0) { static if (i == PT.length) - alias TypeTuple!() Impl; + alias Impl = TypeTuple!(); else - alias TypeTuple!(Get!i, Impl!(i+1)) Impl; + alias Impl = TypeTuple!(Get!i, Impl!(i+1)); } - alias Impl!() ParameterDefaultValueTuple; + alias ParameterDefaultValueTuple = Impl!(); } /// @@ -1128,9 +1130,10 @@ unittest static assert( ParameterDefaultValueTuple!foo[1] == "hello"); static assert( ParameterDefaultValueTuple!foo[2] == [1,2,3]); } + unittest { - alias ParameterDefaultValueTuple PDVT; + alias PDVT = ParameterDefaultValueTuple; void bar(int n = 1, string s = "hello"){} static assert(PDVT!bar.length == 2); @@ -1168,7 +1171,7 @@ Returns the attributes attached to a function $(D func). Example: -------------------- -alias FunctionAttribute FA; // shorten the enum name +alias FA = FunctionAttribute; // shorten the enum name real func(real x) pure nothrow @safe { @@ -1197,7 +1200,7 @@ enum FunctionAttribute : uint template functionAttributes(func...) if (func.length == 1 && isCallable!func) { - alias Unqual!(FunctionTypeOf!func) Func; + alias Func = Unqual!(FunctionTypeOf!func); enum uint functionAttributes = demangleFunctionAttributes(mangledName!Func[1 .. $]).value; @@ -1205,7 +1208,7 @@ template functionAttributes(func...) unittest { - alias FunctionAttribute FA; + alias FA = FunctionAttribute; interface Set { int pureF() pure; @@ -1508,7 +1511,7 @@ assert(b == "C"); // extern(C) template functionLinkage(func...) if (func.length == 1 && isCallable!func) { - alias Unqual!(FunctionTypeOf!func) Func; + alias Func = Unqual!(FunctionTypeOf!func); enum string functionLinkage = [ @@ -1564,7 +1567,7 @@ enum Variadic template variadicFunctionStyle(func...) if (func.length == 1 && isCallable!func) { - alias Unqual!(FunctionTypeOf!func) Func; + alias Func = Unqual!(FunctionTypeOf!func); // TypeFuncion --> CallConvention FuncAttrs Arguments ArgClose Type enum callconv = functionLinkage!Func; @@ -1623,27 +1626,29 @@ template FunctionTypeOf(func...) { static if (is(typeof(& func[0]) Fsym : Fsym*) && is(Fsym == function) || is(typeof(& func[0]) Fsym == delegate)) { - alias Fsym FunctionTypeOf; // HIT: (nested) function symbol + alias FunctionTypeOf = Fsym; // HIT: (nested) function symbol } else static if (is(typeof(& func[0].opCall) Fobj == delegate)) { - alias Fobj FunctionTypeOf; // HIT: callable object + alias FunctionTypeOf = Fobj; // HIT: callable object } else static if (is(typeof(& func[0].opCall) Ftyp : Ftyp*) && is(Ftyp == function)) { - alias Ftyp FunctionTypeOf; // HIT: callable type + alias FunctionTypeOf = Ftyp; // HIT: callable type } else static if (is(func[0] T) || is(typeof(func[0]) T)) { static if (is(T == function)) - alias T FunctionTypeOf; // HIT: function + alias FunctionTypeOf = T; // HIT: function else static if (is(T Fptr : Fptr*) && is(Fptr == function)) - alias Fptr FunctionTypeOf; // HIT: function pointer + alias FunctionTypeOf = Fptr; // HIT: function pointer else static if (is(T Fdlg == delegate)) - alias Fdlg FunctionTypeOf; // HIT: delegate - else static assert(0); + alias FunctionTypeOf = Fdlg; // HIT: delegate + else + static assert(0); } - else static assert(0); + else + static assert(0); } unittest @@ -1684,17 +1689,17 @@ unittest int test(); int test() @property; } - alias TypeTuple!(__traits(getVirtualFunctions, Overloads, "test")) ov; - alias FunctionTypeOf!(ov[0]) F_ov0; - alias FunctionTypeOf!(ov[1]) F_ov1; - alias FunctionTypeOf!(ov[2]) F_ov2; - alias FunctionTypeOf!(ov[3]) F_ov3; + alias ov = TypeTuple!(__traits(getVirtualFunctions, Overloads, "test")); + alias F_ov0 = FunctionTypeOf!(ov[0]); + alias F_ov1 = FunctionTypeOf!(ov[1]); + alias F_ov2 = FunctionTypeOf!(ov[2]); + alias F_ov3 = FunctionTypeOf!(ov[3]); static assert(is(F_ov0* == void function(string))); static assert(is(F_ov1* == real function(real))); static assert(is(F_ov2* == int function())); static assert(is(F_ov3* == int function() @property)); - alias FunctionTypeOf!((int a){ return a; }) F_dglit; + alias F_dglit = FunctionTypeOf!((int a){ return a; }); static assert(is(F_dglit* : int function(int))); } @@ -1712,11 +1717,7 @@ unittest * * Examples: * --- - * template ExternC(T) - * if (isFunctionPointer!T || isDelegate!T || is(T == function)) - * { - * alias SetFunctionAttributes!(T, "C", functionAttributes!T) ExternC; - * } + * alias ExternC(T) = SetFunctionAttributes!(T, "C", functionAttributes!T); * --- * * --- @@ -1811,7 +1812,7 @@ unittest { import std.algorithm : reduce; - alias FunctionAttribute FA; + alias FA = FunctionAttribute; foreach (BaseT; TypeTuple!(typeof(&sc), typeof(&novar), typeof(&cstyle), typeof(&dstyle), typeof(&typesafe))) { @@ -1828,7 +1829,7 @@ unittest { foreach (newLinkage; TypeTuple!("D", "C", "Windows", "Pascal", "C++")) { - alias SetFunctionAttributes!(T, newLinkage, attrs) New; + alias New = SetFunctionAttributes!(T, newLinkage, attrs); static assert(functionLinkage!New == newLinkage, "Linkage test failed for: " ~ T.stringof ~ ", " ~ newLinkage ~ " (got " ~ New.stringof ~ ")"); @@ -1836,16 +1837,16 @@ unittest } // Add @safe. - alias SetFunctionAttributes!(T, functionLinkage!T, FA.safe) T1; + alias T1 = SetFunctionAttributes!(T, functionLinkage!T, FA.safe); static assert(functionAttributes!T1 == FA.safe); // Add all known attributes, excluding conflicting ones. enum allAttrs = reduce!"a | b"([EnumMembers!FA]) & ~FA.safe & ~FA.property; - alias SetFunctionAttributes!(T1, functionLinkage!T, allAttrs) T2; + alias T2 = SetFunctionAttributes!(T1, functionLinkage!T, allAttrs); static assert(functionAttributes!T2 == allAttrs); // Strip all attributes again. - alias SetFunctionAttributes!(T2, functionLinkage!T, FA.none) T3; + alias T3 = SetFunctionAttributes!(T2, functionLinkage!T, FA.none); static assert(is(T3 == T)); } } @@ -1941,15 +1942,14 @@ unittest * If $(D T) isn't a struct, class, or union returns typetuple * with one element $(D T). */ - template FieldTypeTuple(T) { static if (is(T == struct) || is(T == union)) - alias typeof(T.tupleof[0 .. $ - isNested!T]) FieldTypeTuple; + alias FieldTypeTuple = typeof(T.tupleof[0 .. $ - isNested!T]); else static if (is(T == class)) - alias typeof(T.tupleof) FieldTypeTuple; + alias FieldTypeTuple = typeof(T.tupleof); else - alias TypeTuple!T FieldTypeTuple; + alias FieldTypeTuple = TypeTuple!T; } unittest @@ -2020,11 +2020,11 @@ unittest // unittest // { -// alias FieldOffsetsTuple!int T1; +// alias T1 = FieldOffsetsTuple!int; // assert(T1.length == 1 && T1[0] == 0); // // // struct S2 { char a; int b; char c; double d; char e, f; } -// alias FieldOffsetsTuple!S2 T2; +// alias T2 = FieldOffsetsTuple!S2; // //pragma(msg, T2); // static assert(T2.length == 6 // && T2[0] == 0 && T2[1] == 4 && T2[2] == 8 && T2[3] == 16 @@ -2032,13 +2032,13 @@ unittest // // // class C { int a, b, c, d; } // struct S3 { char a; C b; char c; } -// alias FieldOffsetsTuple!S3 T3; +// alias T3 = FieldOffsetsTuple!S3; // //pragma(msg, T2); // static assert(T3.length == 3 // && T3[0] == 0 && T3[1] == 4 && T3[2] == 8); // // // struct S4 { char a; union { int b; char c; } int d; } -// alias FieldOffsetsTuple!S4 T4; +// alias T4 = FieldOffsetsTuple!S4; // //pragma(msg, FieldTypeTuple!S4); // static assert(T4.length == 4 // && T4[0] == 0 && T4[1] == 4 && T4[2] == 8); @@ -2064,20 +2064,19 @@ Example: ---- struct S1 { int a; float b; } struct S2 { char[] a; union { S1 b; S1 * c; } } -alias RepresentationTypeTuple!S2 R; +alias R = RepresentationTypeTuple!S2; assert(R.length == 4 && is(R[0] == char[]) && is(R[1] == int) && is(R[2] == float) && is(R[3] == S1*)); ---- */ - template RepresentationTypeTuple(T) { template Impl(T...) { static if (T.length == 0) { - alias TypeTuple!() Impl; + alias Impl = TypeTuple!(); } else { @@ -2085,43 +2084,43 @@ template RepresentationTypeTuple(T) static if (is(T[0] R: Rebindable!R)) { - alias Impl!(Impl!R, T[1 .. $]) Impl; + alias Impl = Impl!(Impl!R, T[1 .. $]); } else static if (is(T[0] == struct) || is(T[0] == union)) { // @@@BUG@@@ this should work //alias .RepresentationTypes!(T[0].tupleof) // RepresentationTypes; - alias Impl!(FieldTypeTuple!(T[0]), T[1 .. $]) Impl; + alias Impl = Impl!(FieldTypeTuple!(T[0]), T[1 .. $]); } else static if (is(T[0] U == typedef)) { - alias Impl!(FieldTypeTuple!U, T[1 .. $]) Impl; + alias Impl = Impl!(FieldTypeTuple!U, T[1 .. $]); } else { - alias TypeTuple!(T[0], Impl!(T[1 .. $])) Impl; + alias Impl = TypeTuple!(T[0], Impl!(T[1 .. $])); } } } static if (is(T == struct) || is(T == union) || is(T == class)) { - alias Impl!(FieldTypeTuple!T) RepresentationTypeTuple; + alias RepresentationTypeTuple = Impl!(FieldTypeTuple!T); } else static if (is(T U == typedef)) { - alias RepresentationTypeTuple!U RepresentationTypeTuple; + alias RepresentationTypeTuple = RepresentationTypeTuple!U; } else { - alias Impl!T RepresentationTypeTuple; + alias RepresentationTypeTuple = Impl!T; } } unittest { - alias RepresentationTypeTuple!int S1; + alias S1 = RepresentationTypeTuple!int; static assert(is(S1 == TypeTuple!int)); struct S2 { int a; } @@ -2133,20 +2132,20 @@ unittest struct S11 { int a; float b; } struct S21 { char[] a; union { S11 b; S11 * c; } } - alias RepresentationTypeTuple!S21 R; + alias R = RepresentationTypeTuple!S21; assert(R.length == 4 && is(R[0] == char[]) && is(R[1] == int) && is(R[2] == float) && is(R[3] == S11*)); class C { int a; float b; } - alias RepresentationTypeTuple!C R1; + alias R1 = RepresentationTypeTuple!C; static assert(R1.length == 2 && is(R1[0] == int) && is(R1[1] == float)); /* Issue 6642 */ import std.typecons : Rebindable; struct S5 { int a; Rebindable!(immutable Object) b; } - alias RepresentationTypeTuple!S5 R2; + alias R2 = RepresentationTypeTuple!S5; static assert(R2.length == 2 && is(R2[0] == int) && is(R2[1] == immutable(Object))); } @@ -3140,7 +3139,7 @@ unittest static assert( hasElaborateDestructor!S7); } -template Identity(alias A) { alias A Identity; } +alias Identity(alias A) = A; /** Yields $(D true) if and only if $(D T) is an aggregate that defines @@ -3152,7 +3151,7 @@ template hasMember(T, string name) { enum bool hasMember = staticIndexOf!(name, __traits(allMembers, T)) != -1 || - __traits(compiles, { mixin("alias Identity!(T."~name~") Sym;"); }); + __traits(compiles, { mixin("alias Sym = Identity!(T."~name~");"); }); } else { @@ -3288,7 +3287,7 @@ template EnumMembers(E) { mixin("template Symbolize(alias "~ ident ~")" ~"{" - ~"alias "~ ident ~" Symbolize;" + ~"alias Symbolize = "~ ident ~";" ~"}"); } } @@ -3297,19 +3296,20 @@ template EnumMembers(E) { static if (names.length > 0) { - alias TypeTuple!( + alias EnumSpecificMembers = + TypeTuple!( WithIdentifier!(names[0]) .Symbolize!(__traits(getMember, E, names[0])), EnumSpecificMembers!(names[1 .. $]) - ) EnumSpecificMembers; + ); } else { - alias TypeTuple!() EnumSpecificMembers; + alias EnumSpecificMembers = TypeTuple!(); } } - alias EnumSpecificMembers!(__traits(allMembers, E)) EnumMembers; + alias EnumMembers = EnumSpecificMembers!(__traits(allMembers, E)); } unittest @@ -3371,7 +3371,7 @@ unittest * * void main() * { - * alias BaseTypeTuple!B TL; + * alias TL = BaseTypeTuple!B; * writeln(typeid(TL)); // prints: (A,I) * } * --- @@ -3380,7 +3380,7 @@ unittest template BaseTypeTuple(A) { static if (is(A P == super)) - alias P BaseTypeTuple; + alias BaseTypeTuple = P; else static assert(0, "argument is not a class or interface"); } @@ -3404,7 +3404,7 @@ unittest class A { } class C : A, I1, I2 { } - alias BaseTypeTuple!C TL; + alias TL = BaseTypeTuple!C; assert(TL.length == 3); assert(is (TL[0] == A)); assert(is (TL[1] == I1)); @@ -3428,7 +3428,7 @@ unittest * * void main() * { - * alias BaseClassesTuple!C TL; + * alias TL = BaseClassesTuple!C; * writeln(typeid(TL)); // prints: (B,A,Object) * } * --- @@ -3439,17 +3439,17 @@ template BaseClassesTuple(T) { static if (is(T == Object)) { - alias TypeTuple!() BaseClassesTuple; + alias BaseClassesTuple = TypeTuple!(); } else static if (is(BaseTypeTuple!T[0] == Object)) { - alias TypeTuple!Object BaseClassesTuple; + alias BaseClassesTuple = TypeTuple!Object; } else { - alias TypeTuple!(BaseTypeTuple!T[0], - BaseClassesTuple!(BaseTypeTuple!T[0])) - BaseClassesTuple; + alias BaseClassesTuple = + TypeTuple!(BaseTypeTuple!T[0], + BaseClassesTuple!(BaseTypeTuple!T[0])); } } @@ -3489,7 +3489,7 @@ unittest * * void main() * { - * alias InterfacesTuple!C TL; + * alias TL = InterfacesTuple!C; * writeln(typeid(TL)); // prints: (I1, I2) * } * --- @@ -3501,21 +3501,21 @@ template InterfacesTuple(T) { static if (T.length) { - alias TypeTuple!(Flatten!H, Flatten!T) Flatten; + alias Flatten = TypeTuple!(Flatten!H, Flatten!T); } else { static if (is(H == interface)) - alias TypeTuple!(H, InterfacesTuple!H) Flatten; + alias Flatten = TypeTuple!(H, InterfacesTuple!H); else - alias InterfacesTuple!H Flatten; + alias Flatten = InterfacesTuple!H; } } static if (is(T S == super) && S.length) - alias NoDuplicates!(Flatten!S) InterfacesTuple; + alias InterfacesTuple = NoDuplicates!(Flatten!S); else - alias TypeTuple!() InterfacesTuple; + alias InterfacesTuple = TypeTuple!(); } unittest @@ -3527,7 +3527,7 @@ unittest class A : I1, I2 { } class B : A, I1 { } class C : B { } - alias InterfacesTuple!C TL; + alias TL = InterfacesTuple!C; static assert(is(TL[0] == I1) && is(TL[1] == I2)); } { @@ -3564,7 +3564,7 @@ unittest * * void main() * { - * alias TransitiveBaseTypeTuple!C TL; + * alias TL = TransitiveBaseTypeTuple!C; * writeln(typeid(TL)); // prints: (B,A,Object,I) * } * --- @@ -3573,10 +3573,10 @@ unittest template TransitiveBaseTypeTuple(T) { static if (is(T == Object)) - alias TypeTuple!() TransitiveBaseTypeTuple; + alias TransitiveBaseTypeTuple = TypeTuple!(); else - alias TypeTuple!(BaseClassesTuple!T, InterfacesTuple!T) - TransitiveBaseTypeTuple; + alias TransitiveBaseTypeTuple = + TypeTuple!(BaseClassesTuple!T, InterfacesTuple!T); } unittest @@ -3586,7 +3586,7 @@ unittest class B1 {} class B2 : B1, J1, J2 {} class B3 : B2, J1 {} - alias TransitiveBaseTypeTuple!B3 TL; + alias TL = TransitiveBaseTypeTuple!B3; assert(TL.length == 5); assert(is (TL[0] == B2)); assert(is (TL[1] == B1)); @@ -3725,15 +3725,15 @@ unittest { override C test() { return this; } } - alias MemberFunctionsTuple!(C, "test") test; + alias test =MemberFunctionsTuple!(C, "test"); static assert(test.length == 2); static assert(is(FunctionTypeOf!(test[0]) == FunctionTypeOf!(C.test))); static assert(is(FunctionTypeOf!(test[1]) == FunctionTypeOf!(K.test))); - alias MemberFunctionsTuple!(C, "noexist") noexist; + alias noexist = MemberFunctionsTuple!(C, "noexist"); static assert(noexist.length == 0); interface L { int prop() @property; } - alias MemberFunctionsTuple!(L, "prop") prop; + alias prop = MemberFunctionsTuple!(L, "prop"); static assert(prop.length == 1); interface Test_I @@ -3743,7 +3743,7 @@ unittest void foo(int, int); } interface Test : Test_I {} - alias MemberFunctionsTuple!(Test, "foo") Test_foo; + alias Test_foo = MemberFunctionsTuple!(Test, "foo"); static assert(Test_foo.length == 3); static assert(is(typeof(&Test_foo[0]) == void function())); static assert(is(typeof(&Test_foo[2]) == void function(int))); @@ -3858,8 +3858,9 @@ Returns class instance alignment. */ template classInstanceAlignment(T) if(is(T == class)) { - alias maxAlignment!(void*, typeof(T.tupleof)) classInstanceAlignment; + alias classInstanceAlignment = maxAlignment!(void*, typeof(T.tupleof)); } + /// unittest { @@ -3886,26 +3887,27 @@ template CommonType(T...) { static if (!T.length) { - alias void CommonType; + alias CommonType = void; } else static if (T.length == 1) { static if(is(typeof(T[0]))) { - alias typeof(T[0]) CommonType; + alias CommonType = typeof(T[0]); } else { - alias T[0] CommonType; + alias CommonType = T[0]; } } else static if (is(typeof(true ? T[0].init : T[1].init) U)) { - alias CommonType!(U, T[2 .. $]) CommonType; + alias CommonType = CommonType!(U, T[2 .. $]); } else - alias void CommonType; + alias CommonType = void; } + /// unittest { @@ -3937,64 +3939,59 @@ unittest template ImplicitConversionTargets(T) { static if (is(T == bool)) - alias TypeTuple!(byte, ubyte, short, ushort, int, uint, long, ulong, - float, double, real, char, wchar, dchar) - ImplicitConversionTargets; + alias ImplicitConversionTargets = + TypeTuple!(byte, ubyte, short, ushort, int, uint, long, ulong, + float, double, real, char, wchar, dchar); else static if (is(T == byte)) - alias TypeTuple!(short, ushort, int, uint, long, ulong, - float, double, real, char, wchar, dchar) - ImplicitConversionTargets; + alias ImplicitConversionTargets = + TypeTuple!(short, ushort, int, uint, long, ulong, + float, double, real, char, wchar, dchar); else static if (is(T == ubyte)) - alias TypeTuple!(short, ushort, int, uint, long, ulong, - float, double, real, char, wchar, dchar) - ImplicitConversionTargets; + alias ImplicitConversionTargets = + TypeTuple!(short, ushort, int, uint, long, ulong, + float, double, real, char, wchar, dchar); else static if (is(T == short)) - alias TypeTuple!(int, uint, long, ulong, float, double, real) - ImplicitConversionTargets; + alias ImplicitConversionTargets = + TypeTuple!(int, uint, long, ulong, float, double, real); else static if (is(T == ushort)) - alias TypeTuple!(int, uint, long, ulong, float, double, real) - ImplicitConversionTargets; + alias ImplicitConversionTargets = + TypeTuple!(int, uint, long, ulong, float, double, real); else static if (is(T == int)) - alias TypeTuple!(long, ulong, float, double, real) - ImplicitConversionTargets; + alias ImplicitConversionTargets = + TypeTuple!(long, ulong, float, double, real); else static if (is(T == uint)) - alias TypeTuple!(long, ulong, float, double, real) - ImplicitConversionTargets; + alias ImplicitConversionTargets = + TypeTuple!(long, ulong, float, double, real); else static if (is(T == long)) - alias TypeTuple!(float, double, real) - ImplicitConversionTargets; + alias ImplicitConversionTargets = TypeTuple!(float, double, real); else static if (is(T == ulong)) - alias TypeTuple!(float, double, real) - ImplicitConversionTargets; + alias ImplicitConversionTargets = TypeTuple!(float, double, real); else static if (is(T == float)) - alias TypeTuple!(double, real) - ImplicitConversionTargets; + alias ImplicitConversionTargets = TypeTuple!(double, real); else static if (is(T == double)) - alias TypeTuple!real - ImplicitConversionTargets; + alias ImplicitConversionTargets = TypeTuple!real; else static if (is(T == char)) - alias TypeTuple!(wchar, dchar, byte, ubyte, short, ushort, - int, uint, long, ulong, float, double, real) - ImplicitConversionTargets; + alias ImplicitConversionTargets = + TypeTuple!(wchar, dchar, byte, ubyte, short, ushort, + int, uint, long, ulong, float, double, real); else static if (is(T == wchar)) - alias TypeTuple!(dchar, short, ushort, int, uint, long, ulong, - float, double, real) - ImplicitConversionTargets; + alias ImplicitConversionTargets = + TypeTuple!(dchar, short, ushort, int, uint, long, ulong, + float, double, real); else static if (is(T == dchar)) - alias TypeTuple!(int, uint, long, ulong, - float, double, real) - ImplicitConversionTargets; + alias ImplicitConversionTargets = + TypeTuple!(int, uint, long, ulong, float, double, real); else static if (is(T : typeof(null))) - alias TypeTuple!(typeof(null)) ImplicitConversionTargets; + alias ImplicitConversionTargets = TypeTuple!(typeof(null)); else static if(is(T : Object)) - alias TransitiveBaseTypeTuple!(T) ImplicitConversionTargets; + alias ImplicitConversionTargets = TransitiveBaseTypeTuple!(T); else static if (isDynamicArray!T && !is(typeof(T.init[0]) == const)) alias ImplicitConversionTargets = TypeTuple!(const(Unqual!(typeof(T.init[0])))[]); else static if (is(T : void*)) - alias TypeTuple!(void*) ImplicitConversionTargets; + alias ImplicitConversionTargets = TypeTuple!(void*); else - alias TypeTuple!() ImplicitConversionTargets; + alias ImplicitConversionTargets = TypeTuple!(); } unittest @@ -4229,11 +4226,12 @@ classes of the arguments. */ private template isStorageClassImplicitlyConvertible(From, To) { + alias Pointify(T) = void*; + enum isStorageClassImplicitlyConvertible = isImplicitlyConvertible!( ModifyTypePreservingSTC!(Pointify, From), ModifyTypePreservingSTC!(Pointify, To) ); } -private template Pointify(T) { alias void* Pointify; } unittest { @@ -4278,8 +4276,8 @@ template isCovariantWith(F, G) enum isCovariantWith = true; else { - alias F Upr; - alias G Lwr; + alias Upr = F; + alias Lwr = G; /* * Check for calling convention: require exact match. @@ -4313,7 +4311,7 @@ template isCovariantWith(F, G) */ template checkAttributes() { - alias FunctionAttribute FA; + alias FA = FunctionAttribute; enum uprAtts = functionAttributes!Upr; enum lwrAtts = functionAttributes!Lwr; // @@ -4340,11 +4338,11 @@ template isCovariantWith(F, G) */ template checkParameters() { - alias ParameterStorageClass STC; - alias ParameterTypeTuple!Upr UprParams; - alias ParameterTypeTuple!Lwr LwrParams; - alias ParameterStorageClassTuple!Upr UprPSTCs; - alias ParameterStorageClassTuple!Lwr LwrPSTCs; + alias STC = ParameterStorageClass; + alias UprParams = ParameterTypeTuple!Upr; + alias LwrParams = ParameterTypeTuple!Lwr; + alias UprPSTCs = ParameterStorageClassTuple!Upr; + alias LwrPSTCs = ParameterStorageClassTuple!Lwr; // template checkNext(size_t i) { @@ -4379,12 +4377,10 @@ template isCovariantWith(F, G) } } -version (unittest) private template isCovariantWith(alias f, alias g) -{ - enum bool isCovariantWith = isCovariantWith!(typeof(f), typeof(g)); -} unittest { + enum bool isCovariantWith(alias f, alias g) = .isCovariantWith!(typeof(f), typeof(g)); + // covariant return type interface I {} interface J : I {} @@ -4395,9 +4391,9 @@ unittest static assert( isCovariantWith!(DerivA_2.test, BaseA.test)); static assert(!isCovariantWith!(BaseA.test, DerivA_1.test)); static assert(!isCovariantWith!(BaseA.test, DerivA_2.test)); - static assert(isCovariantWith!(BaseA.test, BaseA.test)); - static assert(isCovariantWith!(DerivA_1.test, DerivA_1.test)); - static assert(isCovariantWith!(DerivA_2.test, DerivA_2.test)); + static assert( isCovariantWith!(BaseA.test, BaseA.test)); + static assert( isCovariantWith!(DerivA_1.test, DerivA_1.test)); + static assert( isCovariantWith!(DerivA_2.test, DerivA_2.test)); // scope parameter interface BaseB { void test( int, int); } @@ -4840,8 +4836,8 @@ unittest { static assert(is(Q!T[] == StringTypeOf!( SubTypeOf!(Q!T[]) ))); - alias Q!T[] Str; - class C(Str) { Str val; alias val this; } + alias Str = Q!T[]; + class C(S) { S val; alias val this; } static assert(is(StringTypeOf!(C!Str) == Str)); } } @@ -4913,10 +4909,7 @@ template BuiltinTypeOf(T) /** * Detect whether $(D T) is a built-in boolean type. */ -template isBoolean(T) -{ - enum bool isBoolean = is(BooleanTypeOf!T) && !isAggregateType!T; -} +enum bool isBoolean(T) = is(BooleanTypeOf!T) && !isAggregateType!T; unittest { @@ -4930,10 +4923,7 @@ unittest * Detect whether $(D T) is a built-in integral type. Types $(D bool), * $(D char), $(D wchar), and $(D dchar) are not considered integral. */ -template isIntegral(T) -{ - enum bool isIntegral = is(IntegralTypeOf!T) && !isAggregateType!T; -} +enum bool isIntegral(T) = is(IntegralTypeOf!T) && !isAggregateType!T; unittest { @@ -4957,10 +4947,7 @@ unittest /** * Detect whether $(D T) is a built-in floating point type. */ -template isFloatingPoint(T) -{ - enum bool isFloatingPoint = is(FloatingPointTypeOf!T) && !isAggregateType!T; -} +enum bool isFloatingPoint(T) = is(FloatingPointTypeOf!T) && !isAggregateType!T; unittest { @@ -4987,10 +4974,7 @@ unittest Detect whether $(D T) is a built-in numeric type (integral or floating point). */ -template isNumeric(T) -{ - enum bool isNumeric = is(NumericTypeOf!T) && !isAggregateType!T; -} +enum bool isNumeric(T) = is(NumericTypeOf!T) && !isAggregateType!T; unittest { @@ -5007,10 +4991,7 @@ unittest /** Detect whether $(D T) is a scalar type (a built-in numeric, character or boolean type). */ -template isScalarType(T) -{ - enum bool isScalarType = isNumeric!T || isSomeChar!T || isBoolean!T; -} +enum bool isScalarType(T) = isNumeric!T || isSomeChar!T || isBoolean!T; unittest { @@ -5024,10 +5005,7 @@ unittest /** Detect whether $(D T) is a basic type (scalar type or void). */ -template isBasicType(T) -{ - enum bool isBasicType = isScalarType!T || is(T == void); -} +enum bool isBasicType(T) = isScalarType!T || is(T == void); unittest { @@ -5041,10 +5019,7 @@ unittest /** Detect whether $(D T) is a built-in unsigned numeric type. */ -template isUnsigned(T) -{ - enum bool isUnsigned = is(UnsignedTypeOf!T) && !isAggregateType!T; -} +enum bool isUnsigned(T) = is(UnsignedTypeOf!T) && !isAggregateType!T; unittest { @@ -5061,10 +5036,7 @@ unittest /** Detect whether $(D T) is a built-in signed numeric type. */ -template isSigned(T) -{ - enum bool isSigned = is(SignedTypeOf!T) && !isAggregateType!T; -} +enum bool isSigned(T) = is(SignedTypeOf!T) && !isAggregateType!T; unittest { @@ -5081,10 +5053,7 @@ unittest /** Detect whether $(D T) is one of the built-in character types. */ -template isSomeChar(T) -{ - enum isSomeChar = is(CharTypeOf!T) && !isAggregateType!T; -} +enum bool isSomeChar(T) = is(CharTypeOf!T) && !isAggregateType!T; unittest { @@ -5110,10 +5079,7 @@ unittest /** Detect whether $(D T) is one of the built-in string types. */ -template isSomeString(T) -{ - enum isSomeString = is(StringTypeOf!T) && !isAggregateType!T; -} +enum bool isSomeString(T) = is(StringTypeOf!T) && !isAggregateType!T; unittest { @@ -5132,10 +5098,7 @@ unittest static assert( isSomeString!ES); } -template isNarrowString(T) -{ - enum isNarrowString = (is(T : const char[]) || is(T : const wchar[])) && !isAggregateType!T; -} +enum bool isNarrowString(T) = (is(T : const char[]) || is(T : const wchar[])) && !isAggregateType!T; unittest { @@ -5161,10 +5124,7 @@ unittest /** * Detect whether type $(D T) is a static array. */ -template isStaticArray(T) -{ - enum isStaticArray = is(StaticArrayTypeOf!T) && !isAggregateType!T; -} +enum bool isStaticArray(T) = is(StaticArrayTypeOf!T) && !isAggregateType!T; unittest { @@ -5195,10 +5155,7 @@ unittest /** * Detect whether type $(D T) is a dynamic array. */ -template isDynamicArray(T) -{ - enum isDynamicArray = is(DynamicArrayTypeOf!T) && !isAggregateType!T; -} +enum bool isDynamicArray(T) = is(DynamicArrayTypeOf!T) && !isAggregateType!T; unittest { @@ -5221,10 +5178,7 @@ unittest /** * Detect whether type $(D T) is an array. */ -template isArray(T) -{ - enum bool isArray = isStaticArray!T || isDynamicArray!T; -} +enum bool isArray(T) = isStaticArray!T || isDynamicArray!T; unittest { @@ -5245,10 +5199,7 @@ unittest /** * Detect whether $(D T) is an associative array type */ -template isAssociativeArray(T) -{ - enum bool isAssociativeArray = is(AssocArrayTypeOf!T) && !isAggregateType!T; -} +enum bool isAssociativeArray(T) = is(AssocArrayTypeOf!T) && !isAggregateType!T; unittest { @@ -5276,21 +5227,12 @@ unittest //static assert( isAssociativeArray!EAA); } -template isBuiltinType(T) -{ - enum isBuiltinType = is(BuiltinTypeOf!T) && !isAggregateType!T; -} +enum bool isBuiltinType(T) = is(BuiltinTypeOf!T) && !isAggregateType!T; /** * Detect whether type $(D T) is a pointer. */ -template isPointer(T) -{ - static if (is(T P == U*, U) && !isAggregateType!T) - enum isPointer = true; - else - enum isPointer = false; -} +enum bool isPointer(T) = is(T == U*, U) && !isAggregateType!T; unittest { @@ -5312,13 +5254,10 @@ unittest /** Returns the target type of a pointer. */ -template PointerTarget(T : T*) -{ - alias T PointerTarget; -} +alias PointerTarget(T : T*) = T; /// $(RED Scheduled for deprecation. Please use $(LREF PointerTarget) instead.) -alias PointerTarget pointerTarget; +alias pointerTarget = PointerTarget; unittest { @@ -5331,11 +5270,8 @@ unittest /** * Detect whether type $(D T) is an aggregate type. */ -template isAggregateType(T) -{ - enum isAggregateType = is(T == struct) || is(T == union) || - is(T == class) || is(T == interface); -} +enum bool isAggregateType(T) = is(T == struct) || is(T == union) || + is(T == class) || is(T == interface); /** * Returns $(D true) if T can be iterated over using a $(D foreach) loop with @@ -5344,10 +5280,7 @@ template isAggregateType(T) * that define $(D opApply) with a single loop variable, and builtin dynamic, * static and associative arrays. */ -template isIterable(T) -{ - enum isIterable = is(typeof({ foreach(elem; T.init) {} })); -} +enum bool isIterable(T) = is(typeof({ foreach(elem; T.init) {} })); unittest { @@ -5375,10 +5308,7 @@ unittest * Returns true if T is not const or immutable. Note that isMutable is true for * string, or immutable(char)[], because the 'head' is mutable. */ -template isMutable(T) -{ - enum isMutable = !is(T == const) && !is(T == immutable) && !is(T == inout); -} +enum bool isMutable(T) = !is(T == const) && !is(T == immutable) && !is(T == inout); unittest { @@ -5397,13 +5327,7 @@ unittest /** * Returns true if T is an instance of the template S. */ -template isInstanceOf(alias S, T) -{ - static if (is(T x == S!Args, Args...)) - enum bool isInstanceOf = true; - else - enum bool isInstanceOf = false; -} +enum bool isInstanceOf(alias S, T) = is(T == S!Args, Args...); unittest { @@ -5440,7 +5364,7 @@ unittest void foo(); static int bar() { return 42; } enum aa = [ 1: -1 ]; - alias int myint; + alias myint = int; static assert( isExpressionTuple!(42)); static assert( isExpressionTuple!aa); @@ -5772,11 +5696,11 @@ template Unqual(T) { version (none) // Error: recursive alias declaration @@@BUG1308@@@ { - static if (is(T U == const U)) alias Unqual!U Unqual; - else static if (is(T U == immutable U)) alias Unqual!U Unqual; - else static if (is(T U == inout U)) alias Unqual!U Unqual; - else static if (is(T U == shared U)) alias Unqual!U Unqual; - else alias T Unqual; + static if (is(T U == const U)) alias Unqual = Unqual!U; + else static if (is(T U == immutable U)) alias Unqual = Unqual!U; + else static if (is(T U == inout U)) alias Unqual = Unqual!U; + else static if (is(T U == shared U)) alias Unqual = Unqual!U; + else alias Unqual = T; } else // workaround { @@ -5804,7 +5728,7 @@ unittest static assert(is(Unqual!(shared inout const int) == int)); static assert(is(Unqual!( immutable int) == int)); - alias immutable(int[]) ImmIntArr; + alias ImmIntArr = immutable(int[]); static assert(is(Unqual!ImmIntArr == immutable(int)[])); } @@ -5845,7 +5769,7 @@ has both opApply and a range interface. */ template ForeachType(T) { - alias ReturnType!(typeof( + alias ForeachType = ReturnType!(typeof( (inout int x = 0) { foreach(elem; T.init) @@ -5853,7 +5777,7 @@ template ForeachType(T) return elem; } assert(0); - })) ForeachType; + })); } unittest @@ -5880,12 +5804,12 @@ template OriginalType(T) { template Impl(T) { - static if (is(T U == typedef)) alias OriginalType!U Impl; - else static if (is(T U == enum)) alias OriginalType!U Impl; - else alias T Impl; + static if (is(T U == typedef)) alias Impl = OriginalType!U; + else static if (is(T U == enum)) alias Impl = OriginalType!U; + else alias Impl = T; } - alias ModifyTypePreservingSTC!(Impl, T) OriginalType; + alias OriginalType = ModifyTypePreservingSTC!(Impl, T); } unittest @@ -5907,10 +5831,8 @@ unittest /** * Get the Key type of an Associative Array. */ -template KeyType(V : V[K], K) -{ - alias K KeyType; -} +alias KeyType(V : V[K], K) = K; + /// unittest { @@ -5925,10 +5847,8 @@ unittest /** * Get the Value type of an Associative Array. */ -template ValueType(V : V[K], K) -{ - alias V ValueType; -} +alias ValueType(V : V[K], K) = V; + /// unittest { @@ -5962,20 +5882,20 @@ template Unsigned(T) " does not have an Unsigned counterpart"); } - alias ModifyTypePreservingSTC!(Impl, OriginalType!T) Unsigned; + alias Unsigned = ModifyTypePreservingSTC!(Impl, OriginalType!T); } unittest { - alias Unsigned!int U1; - alias Unsigned!(const(int)) U2; - alias Unsigned!(immutable(int)) U3; + alias U1 = Unsigned!int; + alias U2 = Unsigned!(const(int)); + alias U3 = Unsigned!(immutable(int)); static assert(is(U1 == uint)); static assert(is(U2 == const(uint))); static assert(is(U3 == immutable(uint))); //struct S {} - //alias Unsigned!S U2; - //alias Unsigned!double U3; + //alias U2 = Unsigned!S; + //alias U3 = Unsigned!double; } /** @@ -5987,22 +5907,22 @@ template Largest(T...) if(T.length >= 1) { static if (T.length == 1) { - alias T[0] Largest; + alias Largest = T[0]; } else static if (T.length == 2) { static if(T[0].sizeof >= T[1].sizeof) { - alias T[0] Largest; + alias Largest = T[0]; } else { - alias T[1] Largest; + alias Largest = T[1]; } } else { - alias Largest!(Largest!(T[0 .. $/2]), Largest!(T[$/2 .. $])) Largest; + alias Largest = Largest!(Largest!(T[0 .. $/2]), Largest!(T[$/2 .. $])); } } @@ -6036,14 +5956,14 @@ template Signed(T) " does not have an Signed counterpart"); } - alias ModifyTypePreservingSTC!(Impl, OriginalType!T) Signed; + alias Signed = ModifyTypePreservingSTC!(Impl, OriginalType!T); } unittest { - alias Signed!uint S1; - alias Signed!(const(uint)) S2; - alias Signed!(immutable(uint)) S3; + alias S1 = Signed!uint; + alias S2 = Signed!(const(uint)); + alias S3 = Signed!(immutable(uint)); static assert(is(S1 == int)); static assert(is(S2 == const(int))); static assert(is(S3 == immutable(int))); diff --git a/std/typecons.d b/std/typecons.d index 9fbe7f2ab..f50e7eb47 100644 --- a/std/typecons.d +++ b/std/typecons.d @@ -14,11 +14,11 @@ Synopsis: ---- // value tuples -alias Tuple!(float, "x", float, "y", float, "z") Coord; +alias Coord = Tuple!(float, "x", float, "y", float, "z"); Coord c; c[1] = 1; // access by index c.z = 1; // access by given name -alias Tuple!(string, string) DicEntry; // names can be omitted +alias DicEntry = Tuple!(string, string); // names can be omitted // Rebindable references to const and immutable objects void bar() @@ -60,9 +60,10 @@ Example: struct Unique(T) { static if (is(T:Object)) - alias T RefT; + alias RefT = T; else - alias T * RefT; + alias RefT = T*; + public: /+ Doesn't work yet /** @@ -170,7 +171,7 @@ unittest ~this() { writefln(" Bar destructor"); } int val() const { return 4; } } - alias Unique!(Bar) UBar; + alias UBar = Unique!(Bar); UBar g(UBar u) { return u; @@ -194,7 +195,7 @@ unittest ~this() { writefln(" Bar destructor"); } int val() const { return 3; } } - alias Unique!(Foo) UFoo; + alias UFoo = Unique!(Foo); UFoo f(UFoo u) { @@ -246,7 +247,7 @@ members. The method above is still applicable to all fields. Example: ---- -alias Tuple!(int, "index", string, "value") Entry; +alias Entry = Tuple!(int, "index", string, "value"); Entry e; e.index = 4; e.value = "Hello"; @@ -277,19 +278,21 @@ template Tuple(Specs...) { static if (Specs.length == 0) { - alias TypeTuple!() parseSpecs; + alias parseSpecs = TypeTuple!(); } else static if (is(Specs[0])) { static if (is(typeof(Specs[1]) : string)) { - alias TypeTuple!(FieldSpec!(Specs[0 .. 2]), - parseSpecs!(Specs[2 .. $])) parseSpecs; + alias parseSpecs = + TypeTuple!(FieldSpec!(Specs[0 .. 2]), + parseSpecs!(Specs[2 .. $])); } else { - alias TypeTuple!(FieldSpec!(Specs[0]), - parseSpecs!(Specs[1 .. $])) parseSpecs; + alias parseSpecs = + TypeTuple!(FieldSpec!(Specs[0]), + parseSpecs!(Specs[1 .. $])); } } else @@ -301,19 +304,19 @@ template Tuple(Specs...) template FieldSpec(T, string s = "") { - alias T Type; - alias s name; + alias Type = T; + alias name = s; } - alias parseSpecs!Specs fieldSpecs; + alias fieldSpecs = parseSpecs!Specs; // Used with staticMap. - template extractType(alias spec) { alias spec.Type extractType; } - template extractName(alias spec) { alias spec.name extractName; } + alias extractType(alias spec) = spec.Type; + alias extractName(alias spec) = spec.name; // Generates named fields as follows: - // alias Identity!(field[0]) name_0; - // alias Identity!(field[1]) name_1; + // alias name_0 = Identity!(field[0]); + // alias name_1 = Identity!(field[1]); // : // NOTE: field[k] is an expression (which yields a symbol of a // variable) and can't be aliased directly. @@ -324,10 +327,10 @@ template Tuple(Specs...) { import std.string : format; - decl ~= format("alias Identity!(field[%s]) _%s;", i, i); + decl ~= format("alias _%s = Identity!(field[%s]);", i, i); if (name.length != 0) { - decl ~= format("alias _%s %s;", i, name); + decl ~= format("alias %s = _%s;", name, i); } } return decl; @@ -335,21 +338,18 @@ template Tuple(Specs...) // Returns Specs for a subtuple this[from .. to] preserving field // names if any. - template sliceSpecs(size_t from, size_t to) - { - alias staticMap!(expandSpec, - fieldSpecs[from .. to]) sliceSpecs; - } + alias sliceSpecs(size_t from, size_t to) = + staticMap!(expandSpec, fieldSpecs[from .. to]); template expandSpec(alias spec) { static if (spec.name.length == 0) { - alias TypeTuple!(spec.Type) expandSpec; + alias expandSpec = TypeTuple!(spec.Type); } else { - alias TypeTuple!(spec.Type, spec.name) expandSpec; + alias expandSpec = TypeTuple!(spec.Type, spec.name); } } @@ -374,7 +374,7 @@ template Tuple(Specs...) /** * The type of the tuple's components. */ - alias staticMap!(extractType, fieldSpecs) Types; + alias Types = staticMap!(extractType, fieldSpecs); /** * Use $(D t.expand) for a tuple $(D t) to expand it into its @@ -584,20 +584,15 @@ template Tuple(Specs...) } } -private template isPrintable(T) -{ - enum isPrintable = is(typeof({ +private enum bool isPrintable(T) = + is(typeof({ import std.format : formattedWrite; Appender!string w; formattedWrite(w, "%s", T.init); })); -} -private template Identity(alias T) -{ - alias T Identity; -} +private alias Identity(alias T) = T; unittest { @@ -743,7 +738,7 @@ unittest { const int x = 1; auto t1 = tuple(x); - alias Tuple!(const(int)) T; + alias T = Tuple!(const(int)); auto t2 = T(1); } // 9431 @@ -961,11 +956,11 @@ template Rebindable(T) if (is(T == class) || is(T == interface) || isArray!T) { static if (!is(T X == const U, U) && !is(T X == immutable U, U)) { - alias T Rebindable; + alias Rebindable = T; } else static if (isArray!T) { - alias const(ElementType!T)[] Rebindable; + alias Rebindable = const(ElementType!T)[]; } else { @@ -1862,11 +1857,7 @@ void main() See_Also: AutoImplement, generateEmptyFunction */ -template BlackHole(Base) -{ - alias AutoImplement!(Base, generateEmptyFunction, isAbstractFunction) - BlackHole; -} +alias BlackHole(Base) = AutoImplement!(Base, generateEmptyFunction, isAbstractFunction); unittest { @@ -1933,11 +1924,7 @@ void main() See_Also: AutoImplement, generateAssertTrap */ -template WhiteHole(Base) -{ - alias AutoImplement!(Base, generateAssertTrap, isAbstractFunction) - WhiteHole; -} +alias WhiteHole(Base) = AutoImplement!(Base, generateAssertTrap, isAbstractFunction); // / ditto class NotImplementedError : Error @@ -2036,10 +2023,7 @@ string generateLogger(C, alias fun)() @property -------------------- // Sees if fun returns something. -template hasValue(alias fun) -{ - enum bool hasValue = !is(ReturnType!(fun) == void); -} +enum bool hasValue(alias fun) = !is(ReturnType!(fun) == void); -------------------- @@ -2068,9 +2052,8 @@ $(UL */ class AutoImplement(Base, alias how, alias what = isAbstractFunction) : Base { - private alias AutoImplement_Helper!( - "autoImplement_helper_", "Base", Base, how, what ) - autoImplement_helper_; + private alias autoImplement_helper_ = + AutoImplement_Helper!("autoImplement_helper_", "Base", Base, how, what); mixin(autoImplement_helper_.code); } @@ -2092,15 +2075,15 @@ private static: { static if (lst.length > 0) { - alias staticFilter!(pred, lst[1 .. $]) tail; + alias tail = staticFilter!(pred, lst[1 .. $]); // static if (pred!(lst[0])) - alias TypeTuple!(lst[0], tail) staticFilter; + alias staticFilter = TypeTuple!(lst[0], tail); else - alias tail staticFilter; + alias staticFilter = tail; } else - alias TypeTuple!() staticFilter; + alias staticFilter = TypeTuple!(); } // Returns function overload sets in the class C, filtered with pred. @@ -2110,19 +2093,19 @@ private static: { static if (names.length > 0) { - alias staticFilter!(pred, MemberFunctionsTuple!(C, names[0])) methods; - alias Impl!(names[1 .. $]) next; + alias methods = staticFilter!(pred, MemberFunctionsTuple!(C, names[0])); + alias next = Impl!(names[1 .. $]); static if (methods.length > 0) - alias TypeTuple!(OverloadSet!(names[0], methods), next) Impl; + alias Impl = TypeTuple!(OverloadSet!(names[0], methods), next); else - alias next Impl; + alias Impl = next; } else - alias TypeTuple!() Impl; + alias Impl = TypeTuple!(); } - alias Impl!(__traits(allMembers, C)) enumerateOverloads; + alias enumerateOverloads = Impl!(__traits(allMembers, C)); } //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::// @@ -2130,27 +2113,23 @@ private static: //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::// // Add a non-final check to the cherrypickMethod. - template canonicalPicker(fun.../+[BUG 4217]+/) - { - enum bool canonicalPicker = !__traits(isFinalFunction, fun[0]) && - cherrypickMethod!(fun); - } + enum bool canonicalPicker(fun.../+[BUG 4217]+/) = + !__traits(isFinalFunction, fun[0]) && cherrypickMethod!(fun); /* * A tuple of overload sets, each item of which consists of functions to be * implemented by the generated code. */ - alias enumerateOverloads!(Base, canonicalPicker) targetOverloadSets; + alias targetOverloadSets = enumerateOverloads!(Base, canonicalPicker); /* * A tuple of the super class' constructors. Used for forwarding * constructor calls. */ static if (__traits(hasMember, Base, "__ctor")) - alias OverloadSet!("__ctor", __traits(getOverloads, Base, "__ctor")) - ctorOverloadSet; + alias ctorOverloadSet = OverloadSet!("__ctor", __traits(getOverloads, Base, "__ctor")); else - alias OverloadSet!("__ctor") ctorOverloadSet; // empty + alias ctorOverloadSet = OverloadSet!("__ctor"); // empty //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::// @@ -2195,10 +2174,9 @@ private static: { mixin populate!(name, methods[0 .. $ - 1]); // - alias methods[$ - 1] target; + alias target = methods[$ - 1]; enum ith = methods.length - 1; - mixin( "alias FuncInfo!(target) " ~ - INTERNAL_FUNCINFO_ID!(name, ith) ~ ";" ); + mixin("alias " ~ INTERNAL_FUNCINFO_ID!(name, ith) ~ " = FuncInfo!target;"); } } @@ -2262,10 +2240,8 @@ private static: // Generated code //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::// - alias MemberFunctionGenerator!( ConstructorGeneratingPolicy!() ) - ConstructorGenerator; - alias MemberFunctionGenerator!( MethodGeneratingPolicy!() ) - MethodGenerator; + alias ConstructorGenerator = MemberFunctionGenerator!(ConstructorGeneratingPolicy!()); + alias MethodGenerator = MemberFunctionGenerator!(MethodGeneratingPolicy!()); public enum string code = ConstructorGenerator.generateCode!( ctorOverloadSet ) ~ "\n" ~ @@ -2404,7 +2380,7 @@ Used by MemberFunctionGenerator. package template OverloadSet(string nam, T...) { enum string name = nam; - alias T contents; + alias contents = T; } /* @@ -2412,13 +2388,13 @@ Used by MemberFunctionGenerator. */ package template FuncInfo(alias func, /+[BUG 4217 ?]+/ T = typeof(&func)) { - alias ReturnType!(T) RT; - alias ParameterTypeTuple!(T) PT; + alias RT = ReturnType!T; + alias PT = ParameterTypeTuple!T; } package template FuncInfo(Func) { - alias ReturnType!(Func) RT; - alias ParameterTypeTuple!(Func) PT; + alias RT = ReturnType!Func; + alias PT = ParameterTypeTuple!Func; } /* @@ -2466,24 +2442,21 @@ private static: // preferred identifier for i-th parameter variable static if (__traits(hasMember, Policy, "PARAMETER_VARIABLE_ID")) { - alias Policy.PARAMETER_VARIABLE_ID PARAMETER_VARIABLE_ID; + alias PARAMETER_VARIABLE_ID = Policy.PARAMETER_VARIABLE_ID; } else { - template PARAMETER_VARIABLE_ID(size_t i) - { - enum string PARAMETER_VARIABLE_ID = format("a%s", i); - // default: a0, a1, ... - } + enum string PARAMETER_VARIABLE_ID(size_t i) = format("a%s", i); + // default: a0, a1, ... } // Returns a tuple consisting of 0,1,2,...,n-1. For static foreach. template CountUp(size_t n) { static if (n > 0) - alias TypeTuple!(CountUp!(n - 1), n - 1) CountUp; + alias CountUp = TypeTuple!(CountUp!(n - 1), n - 1); else - alias TypeTuple!() CountUp; + alias CountUp = TypeTuple!(); } @@ -2503,7 +2476,7 @@ private static: foreach (i_; CountUp!(0 + overloads.length)) // workaround { enum i = 0 + i_; // workaround - alias overloads[i] oset; + alias oset = overloads[i]; code ~= generateCodeForOverloadSet!(oset); @@ -2512,9 +2485,10 @@ private static: // The generated function declarations may hide existing ones // in the base class (cf. HiddenFuncError), so we put an alias // declaration here to reveal possible hidden functions. - code ~= format("alias %s.%s %s;\n", + code ~= format("alias %s = %s.%s;\n", + oset.name, Policy.BASE_CLASS_ID, // [BUG 2540] super. - oset.name, oset.name ); + oset.name); } } return code; @@ -2551,8 +2525,8 @@ private static: /*** Function Declarator ***/ { - alias FunctionTypeOf!(func) Func; - alias FunctionAttribute FA; + alias Func = FunctionTypeOf!(func); + alias FA = FunctionAttribute; enum atts = functionAttributes!(func); enum realName = isCtor ? "this" : name; @@ -2618,10 +2592,10 @@ private static: /* Declare keywords: args, self and parent. */ string preamble; - preamble ~= "alias TypeTuple!(" ~ enumerateParameters!(nparams) ~ ") args;\n"; + preamble ~= "alias args = TypeTuple!(" ~ enumerateParameters!(nparams) ~ ");\n"; if (!isCtor) { - preamble ~= "alias " ~ name ~ " self;\n"; + preamble ~= "alias self = " ~ name ~ ";\n"; if (WITH_BASE_CLASS && !__traits(isAbstractFunction, func)) //preamble ~= "alias super." ~ name ~ " parent;\n"; // [BUG 2540] preamble ~= "auto parent = &super." ~ name ~ ";\n"; @@ -2647,8 +2621,8 @@ private static: */ private string generateParameters(string myFuncInfo, func...)() { - alias ParameterStorageClass STC; - alias ParameterStorageClassTuple!(func) stcs; + alias STC = ParameterStorageClass; + alias stcs = ParameterStorageClassTuple!(func); enum nparams = stcs.length; string params = ""; // the result @@ -2925,7 +2899,7 @@ if (Targets.length >= 1 && allSatisfy!(isMutable, Targets)) } static @property mod() { - alias TypeTuple!(TargetMembers[i].type)[0] type; + alias type = TypeTuple!(TargetMembers[i].type)[0]; string r; static if (is(type == immutable)) r ~= " immutable"; else @@ -3449,11 +3423,11 @@ private template staticIota(int beg, int end) { static if (beg >= end) { - alias TypeTuple!() staticIota; + alias staticIota = TypeTuple!(); } else { - alias TypeTuple!(+beg) staticIota; + alias staticIota = TypeTuple!(+beg); } } else @@ -3473,7 +3447,7 @@ private template mixinAll(mixins...) } else { - alias mixins[0] it; + alias it = mixins[0]; mixin it; } } @@ -3486,10 +3460,7 @@ private template mixinAll(mixins...) private template Bind(alias Template, args1...) { - template Bind(args2...) - { - alias Bind = Template!(args1, args2); - } + alias Bind(args2...) = Template!(args1, args2); } @@ -3788,7 +3759,7 @@ unittest U u; } - alias RefCounted!S SRC; + alias SRC = RefCounted!S; } // 6436 @@ -4164,10 +4135,7 @@ unittest /** Library typedef. */ -template Typedef(T) -{ - alias .Typedef!(T, T.init) Typedef; -} +alias Typedef(T) = .Typedef!(T, T.init); /// ditto struct Typedef(T, T init, string cookie=null) @@ -4198,8 +4166,8 @@ unittest static assert(typeof(z).init == 1.0); - alias Typedef!(int, 0, "dollar") Dollar; - alias Typedef!(int, 0, "yen") Yen; + alias Dollar = Typedef!(int, 0, "dollar"); + alias Yen = Typedef!(int, 0, "yen"); static assert(!is(Dollar == Yen)); Typedef!(int[3]) sa; @@ -4251,7 +4219,7 @@ unittest import std.bitmanip; static import core.stdc.config; - alias Typedef!(core.stdc.config.c_ulong) c_ulong; + alias c_ulong = Typedef!(core.stdc.config.c_ulong); static struct Foo { @@ -4277,8 +4245,8 @@ template scoped(T) { // _d_newclass now use default GC alignment (looks like (void*).sizeof * 2 for // small objects). We will just use the maximum of filed alignments. - alias classInstanceAlignment!T alignment; - alias _alignUp!alignment aligned; + alias alignment = classInstanceAlignment!T; + alias aligned = _alignUp!alignment; static struct Scoped { diff --git a/std/typetuple.d b/std/typetuple.d index 98ef0d30a..a6a5523db 100644 --- a/std/typetuple.d +++ b/std/typetuple.d @@ -39,7 +39,7 @@ module std.typetuple; */ template TypeTuple(TList...) { - alias TList TypeTuple; + alias TypeTuple = TList; } /// @@ -97,13 +97,13 @@ unittest private template genericIndexOf(args...) if (args.length >= 1) { - alias Alias!(args[0]) e; - alias args[1 .. $] tuple; + alias e = Alias!(args[0]); + alias tuple = args[1 .. $]; static if (tuple.length) { - alias Alias!(tuple[0]) head; - alias tuple[1 .. $] tail; + alias head = Alias!(tuple[0]); + alias tail = tuple[1 .. $]; static if (isSame!(e, head)) { @@ -144,7 +144,7 @@ unittest } /// Kept for backwards compatibility -alias staticIndexOf IndexOf; +alias IndexOf = staticIndexOf; /** * Returns a typetuple created from TList with the first occurrence, @@ -152,13 +152,13 @@ alias staticIndexOf IndexOf; */ template Erase(T, TList...) { - alias GenericErase!(T, TList).result Erase; + alias Erase = GenericErase!(T, TList).result; } /// Ditto template Erase(alias T, TList...) { - alias GenericErase!(T, TList).result Erase; + alias Erase = GenericErase!(T, TList).result; } /// @@ -173,22 +173,22 @@ unittest private template GenericErase(args...) if (args.length >= 1) { - alias Alias!(args[0]) e; - alias args[1 .. $] tuple; + alias e = Alias!(args[0]); + alias tuple = args[1 .. $] ; static if (tuple.length) { - alias Alias!(tuple[0]) head; - alias tuple[1 .. $] tail; + alias head = Alias!(tuple[0]); + alias tail = tuple[1 .. $]; static if (isSame!(e, head)) - alias tail result; + alias result = tail; else - alias TypeTuple!(head, GenericErase!(e, tail).result) result; + alias result = TypeTuple!(head, GenericErase!(e, tail).result); } else { - alias TypeTuple!() result; + alias result = TypeTuple!(); } } @@ -210,13 +210,13 @@ unittest */ template EraseAll(T, TList...) { - alias GenericEraseAll!(T, TList).result EraseAll; + alias EraseAll = GenericEraseAll!(T, TList).result; } /// Ditto template EraseAll(alias T, TList...) { - alias GenericEraseAll!(T, TList).result EraseAll; + alias EraseAll = GenericEraseAll!(T, TList).result; } /// @@ -232,23 +232,23 @@ unittest private template GenericEraseAll(args...) if (args.length >= 1) { - alias Alias!(args[0]) e; - alias args[1 .. $] tuple; + alias e = Alias!(args[0]); + alias tuple = args[1 .. $]; static if (tuple.length) { - alias Alias!(tuple[0]) head; - alias tuple[1 .. $] tail; - alias GenericEraseAll!(e, tail).result next; + alias head = Alias!(tuple[0]); + alias tail = tuple[1 .. $]; + alias next = GenericEraseAll!(e, tail).result; static if (isSame!(e, head)) - alias next result; + alias result = next; else - alias TypeTuple!(head, next) result; + alias result = TypeTuple!(head, next); } else { - alias TypeTuple!() result; + alias result = TypeTuple!(); } } @@ -271,9 +271,10 @@ unittest template NoDuplicates(TList...) { static if (TList.length == 0) - alias TList NoDuplicates; + alias NoDuplicates = TList; else - alias TypeTuple!(TList[0], NoDuplicates!(EraseAll!(TList[0], TList[1 .. $]))) NoDuplicates; + alias NoDuplicates = + TypeTuple!(TList[0], NoDuplicates!(EraseAll!(TList[0], TList[1 .. $]))); } /// @@ -300,25 +301,25 @@ unittest */ template Replace(T, U, TList...) { - alias GenericReplace!(T, U, TList).result Replace; + alias Replace = GenericReplace!(T, U, TList).result; } /// Ditto template Replace(alias T, U, TList...) { - alias GenericReplace!(T, U, TList).result Replace; + alias Replace = GenericReplace!(T, U, TList).result; } /// Ditto template Replace(T, alias U, TList...) { - alias GenericReplace!(T, U, TList).result Replace; + alias Replace = GenericReplace!(T, U, TList).result; } /// Ditto template Replace(alias T, alias U, TList...) { - alias GenericReplace!(T, U, TList).result Replace; + alias Replace = GenericReplace!(T, U, TList).result; } /// @@ -334,24 +335,24 @@ unittest private template GenericReplace(args...) if (args.length >= 2) { - alias Alias!(args[0]) from; - alias Alias!(args[1]) to; - alias args[2 .. $] tuple; + alias from = Alias!(args[0]); + alias to = Alias!(args[1]); + alias tuple = args[2 .. $]; static if (tuple.length) { - alias Alias!(tuple[0]) head; - alias tuple[1 .. $] tail; + alias head = Alias!(tuple[0]); + alias tail = tuple[1 .. $]; static if (isSame!(from, head)) - alias TypeTuple!(to, tail) result; + alias result = TypeTuple!(to, tail); else - alias TypeTuple!(head, - GenericReplace!(from, to, tail).result) result; + alias result = TypeTuple!(head, + GenericReplace!(from, to, tail).result); } else { - alias TypeTuple!() result; + alias result = TypeTuple!(); } } @@ -380,25 +381,25 @@ unittest */ template ReplaceAll(T, U, TList...) { - alias GenericReplaceAll!(T, U, TList).result ReplaceAll; + alias ReplaceAll = GenericReplaceAll!(T, U, TList).result; } /// Ditto template ReplaceAll(alias T, U, TList...) { - alias GenericReplaceAll!(T, U, TList).result ReplaceAll; + alias ReplaceAll = GenericReplaceAll!(T, U, TList).result; } /// Ditto template ReplaceAll(T, alias U, TList...) { - alias GenericReplaceAll!(T, U, TList).result ReplaceAll; + alias ReplaceAll = GenericReplaceAll!(T, U, TList).result; } /// Ditto template ReplaceAll(alias T, alias U, TList...) { - alias GenericReplaceAll!(T, U, TList).result ReplaceAll; + alias ReplaceAll = GenericReplaceAll!(T, U, TList).result; } /// @@ -414,24 +415,24 @@ unittest private template GenericReplaceAll(args...) if (args.length >= 2) { - alias Alias!(args[0]) from; - alias Alias!(args[1]) to; - alias args[2 .. $] tuple; + alias from = Alias!(args[0]); + alias to = Alias!(args[1]); + alias tuple = args[2 .. $]; static if (tuple.length) { - alias Alias!(tuple[0]) head; - alias tuple[1 .. $] tail; - alias GenericReplaceAll!(from, to, tail).result next; + alias head = Alias!(tuple[0]); + alias tail = tuple[1 .. $]; + alias next = GenericReplaceAll!(from, to, tail).result; static if (isSame!(from, head)) - alias TypeTuple!(to, next) result; + alias result = TypeTuple!(to, next); else - alias TypeTuple!(head, next) result; + alias result = TypeTuple!(head, next); } else { - alias TypeTuple!() result; + alias result = TypeTuple!(); } } @@ -488,11 +489,11 @@ unittest template MostDerived(T, TList...) { static if (TList.length == 0) - alias T MostDerived; + alias MostDerived = T; else static if (is(TList[0] : T)) - alias MostDerived!(TList[0], TList[1 .. $]) MostDerived; + alias MostDerived = MostDerived!(TList[0], TList[1 .. $]); else - alias MostDerived!(T, TList[1 .. $]) MostDerived; + alias MostDerived = MostDerived!(T, TList[1 .. $]); } /// @@ -514,12 +515,13 @@ unittest template DerivedToFront(TList...) { static if (TList.length == 0) - alias TList DerivedToFront; + alias DerivedToFront = TList; else - alias TypeTuple!(MostDerived!(TList[0], TList[1 .. $]), - DerivedToFront!(ReplaceAll!(MostDerived!(TList[0], TList[1 .. $]), - TList[0], - TList[1 .. $]))) DerivedToFront; + alias DerivedToFront = + TypeTuple!(MostDerived!(TList[0], TList[1 .. $]), + DerivedToFront!(ReplaceAll!(MostDerived!(TList[0], TList[1 .. $]), + TList[0], + TList[1 .. $]))); } /// @@ -569,14 +571,14 @@ unittest import std.traits : Unqual; // empty - alias staticMap!(Unqual) Empty; + alias Empty = staticMap!(Unqual); static assert(Empty.length == 0); // single - alias staticMap!(Unqual, const int) Single; + alias Single = staticMap!(Unqual, const int); static assert(is(Single == TypeTuple!int)); - alias staticMap!(Unqual, int, const int, immutable int) T; + alias T = staticMap!(Unqual, int, const int, immutable int); static assert(is(T == TypeTuple!(int, int, int))); } @@ -723,10 +725,7 @@ private version (unittest) */ template templateNot(alias pred) { - template templateNot(T...) - { - enum templateNot = !pred!T; - } + enum templateNot(T...) = !pred!T; } /// @@ -769,7 +768,7 @@ template templateAnd(Preds...) else { static if (Instantiate!(Preds[0], T)) - alias Instantiate!(.templateAnd!(Preds[1 .. $]), T) templateAnd; + alias templateAnd = Instantiate!(.templateAnd!(Preds[1 .. $]), T); else enum templateAnd = false; } @@ -829,7 +828,7 @@ template templateOr(Preds...) static if (Instantiate!(Preds[0], T)) enum templateOr = true; else - alias Instantiate!(.templateOr!(Preds[1 .. $]), T) templateOr; + alias templateOr = Instantiate!(.templateOr!(Preds[1 .. $]), T); } } } @@ -880,8 +879,8 @@ package: // symbols and literal values template Alias(alias a) { - static if (__traits(compiles, { alias a x; })) - alias a Alias; + static if (__traits(compiles, { alias x = a; })) + alias Alias = a; else static if (__traits(compiles, { enum x = a; })) enum Alias = a; else @@ -890,16 +889,16 @@ template Alias(alias a) // types and tuples template Alias(a...) { - alias a Alias; + alias Alias = a; } unittest { enum abc = 1; - static assert(__traits(compiles, { alias Alias!(123) a; })); - static assert(__traits(compiles, { alias Alias!(abc) a; })); - static assert(__traits(compiles, { alias Alias!(int) a; })); - static assert(__traits(compiles, { alias Alias!(1,abc,int) a; })); + static assert(__traits(compiles, { alias a = Alias!(123); })); + static assert(__traits(compiles, { alias a = Alias!(abc); })); + static assert(__traits(compiles, { alias a = Alias!(int); })); + static assert(__traits(compiles, { alias a = Alias!(1,abc,int); })); } @@ -993,7 +992,7 @@ unittest */ private template Pack(T...) { - alias T tuple; + alias tuple = T; // For convenience template equals(U...) @@ -1028,7 +1027,4 @@ unittest */ // TODO: Consider publicly exposing this, maybe even if only for better // understandability of error messages. -template Instantiate(alias Template, Params...) -{ - alias Template!Params Instantiate; -} +alias Instantiate(alias Template, Params...) = Template!Params; diff --git a/std/uni.d b/std/uni.d index 32dd3a25a..cbae2ec75 100644 --- a/std/uni.d +++ b/std/uni.d @@ -942,7 +942,7 @@ private: enum dim = Types.length; size_t[dim] offsets;// offset for level x size_t[dim] sz;// size of level x - alias staticMap!(bitSizeOf, Types) bitWidth; + alias bitWidth = staticMap!(bitSizeOf, Types); size_t[] storage; } @@ -1020,15 +1020,16 @@ unittest unittest {// more bitpacking tests - alias MultiArray!(BitPacked!(size_t, 3) + alias Bitty = + MultiArray!(BitPacked!(size_t, 3) , BitPacked!(size_t, 4) , BitPacked!(size_t, 3) , BitPacked!(size_t, 6) - , bool) Bitty; - alias sliceBits!(13, 16) fn1; - alias sliceBits!( 9, 13) fn2; - alias sliceBits!( 6, 9) fn3; - alias sliceBits!( 0, 6) fn4; + , bool); + alias fn1 = sliceBits!(13, 16); + alias fn2 = sliceBits!( 9, 13); + alias fn3 = sliceBits!( 6, 9); + alias fn4 = sliceBits!( 0, 6); static void check(size_t lvl, MA)(ref MA arr){ for(size_t i = 0; i< arr.length!lvl; i++) assert(arr.slice!(lvl)[i] == i, text("Mismatch on lvl ", lvl, " idx ", i, " value: ", arr.slice!(lvl)[i])); @@ -1411,7 +1412,7 @@ private struct SliceOverIndexed(T) return true; } private: - alias typeof(T.init[0]) Item; + alias Item = typeof(T.init[0]); size_t from, to; T* arr; } @@ -1567,7 +1568,7 @@ template sharMethod(alias uniLowerBound) if(is(T : ElementType!Range)) { import std.functional; - alias binaryFun!_pred pred; + alias pred = binaryFun!_pred; if(range.length == 0) return 0; if(isPowerOf2(range.length)) @@ -1583,8 +1584,8 @@ template sharMethod(alias uniLowerBound) } } -alias sharMethod!uniformLowerBound sharLowerBound; -alias sharMethod!switchUniformLowerBound sharSwitchLowerBound; +alias sharLowerBound = sharMethod!uniformLowerBound; +alias sharSwitchLowerBound = sharMethod!switchUniformLowerBound; unittest { @@ -1761,7 +1762,7 @@ unittest } //build hack -alias Uint24Array!ReallocPolicy _RealArray; +alias _RealArray = Uint24Array!ReallocPolicy; unittest { @@ -1824,13 +1825,13 @@ public template isIntegralPair(T, V=uint) The recommended default type for set of $(CODEPOINTS). For details, see the current implementation: $(LREF InversionList). */ -public alias InversionList!GcPolicy CodepointSet; +public alias CodepointSet = InversionList!GcPolicy; //@@@BUG: std.typecons tuples depend on std.format to produce fields mixin // which relies on std.uni.isGraphical and this chain blows up with Forward reference error // hence below doesn't seem to work -// public alias Tuple!(uint, "a", uint, "b") CodepointInterval; +// public alias CodepointInterval = Tuple!(uint, "a", uint, "b"); /** The recommended type of $(XREF _typecons, Tuple) @@ -2509,8 +2510,8 @@ public: } private: - alias typeof(this) This; - alias size_t Marker; + alias This = typeof(this); + alias Marker = size_t; // a random-access range of integral pairs static struct Intervals(Range) @@ -3202,8 +3203,8 @@ private: foreach(Policy; TypeTuple!(GcPolicy, ReallocPolicy)) { - alias typeof(Uint24Array!Policy.init[]) Range; - alias Uint24Array!Policy U24A; + alias Range = typeof(Uint24Array!Policy.init[]); + alias U24A = Uint24Array!Policy; static assert(isForwardRange!Range); static assert(isBidirectionalRange!Range); static assert(isOutputRange!(Range, uint)); @@ -3238,7 +3239,7 @@ private: version(unittest) { - private alias TypeTuple!(InversionList!GcPolicy, InversionList!ReallocPolicy) AllSets; + private alias AllSets = TypeTuple!(InversionList!GcPolicy, InversionList!ReallocPolicy); } @trusted unittest// core set primitives test @@ -3533,7 +3534,7 @@ template mapTrieIndex(Prefix...) size_t mapTrieIndex(Key)(Key key) if(isValidPrefixForTrie!(Key, Prefix)) { - alias Prefix p; + alias p = Prefix; size_t idx; foreach(i, v; p[0..$-1]) { @@ -3652,7 +3653,7 @@ private: // page at once loop if(state[level].idx_zeros != size_t.max && val == T.init) { - alias typeof(table.slice!(level-1)[0]) NextIdx; + alias NextIdx = typeof(table.slice!(level-1)[0]); addValue!(level-1)(force!NextIdx(state[level].idx_zeros), numVals/pageSize); ptr = table.slice!level; //table structure might have changed @@ -3689,7 +3690,7 @@ private: // it also makes sure that previous levels point to the correct page in this level void spillToNextPageImpl(size_t level, Slice)(ref Slice ptr) { - alias typeof(table.slice!(level-1)[0]) NextIdx; + alias NextIdx = typeof(table.slice!(level-1)[0]); NextIdx next_lvl_index; enum pageSize = 1< 0) - alias TypeTuple!(sliceBits!(top - sizes[0], top) - , GetBitSlicing!(top - sizes[0], sizes[1..$])) GetBitSlicing; + alias GetBitSlicing = + TypeTuple!(sliceBits!(top - sizes[0], top), + GetBitSlicing!(top - sizes[0], sizes[1..$])); else - alias TypeTuple!() GetBitSlicing; + alias GetBitSlicing = TypeTuple!(); } template callableWith(T) @@ -4481,8 +4483,8 @@ struct sliceBits(size_t from, size_t to) uint low_8(uint x) { return x&0xFF; } @safe pure nothrow uint midlow_8(uint x){ return (x&0xFF00)>>8; } -alias assumeSize!(low_8, 8) lo8; -alias assumeSize!(midlow_8, 8) mlo8; +alias lo8 = assumeSize!(low_8, 8); +alias mlo8 = assumeSize!(midlow_8, 8); static assert(bitSizeOf!lo8 == 8); static assert(bitSizeOf!(sliceBits!(4, 7)) == 3); @@ -4491,9 +4493,9 @@ static assert(bitSizeOf!(BitPacked!(uint, 2)) == 2); template Sequence(size_t start, size_t end) { static if(start < end) - alias TypeTuple!(start, Sequence!(start+1, end)) Sequence; + alias Sequence = TypeTuple!(start, Sequence!(start+1, end)); else - alias TypeTuple!() Sequence; + alias Sequence = TypeTuple!(); } //---- TRIE TESTS ---- @@ -4521,8 +4523,8 @@ unittest } } //@@@BUG link failure, lambdas not found by linker somehow (in case of trie2) - // alias assumeSize!(8, function (uint x) { return x&0xFF; }) lo8; - // alias assumeSize!(7, function (uint x) { return (x&0x7F00)>>8; }) next8; + // alias lo8 = assumeSize!(8, function (uint x) { return x&0xFF; }); + // alias next8 = assumeSize!(7, function (uint x) { return (x&0x7F00)>>8; }); alias CodepointSet Set; auto set = Set('A','Z','a','z'); auto trie = buildTrie!(bool, uint, 256, lo8)(set.byInterval);// simple bool array @@ -4620,7 +4622,7 @@ template idxTypes(Key, size_t fullBits, Prefix...) { static if(Prefix.length == 1) {// the last level is value level, so no index once reduced to 1-level - alias TypeTuple!() idxTypes; + alias idxTypes = TypeTuple!(); } else { @@ -4629,10 +4631,11 @@ template idxTypes(Key, size_t fullBits, Prefix...) // The bottom level is known to hold full bit width // thus it's size in pages is full_bit_width - size_of_last_prefix // Recourse on this notion - alias TypeTuple!( - idxTypes!(Key, fullBits - bitSizeOf!(Prefix[$-1]), Prefix[0..$-1]), - BitPacked!(typeof(Prefix[$-2](Key.init)), fullBits - bitSizeOf!(Prefix[$-1])) - ) idxTypes; + alias idxTypes = + TypeTuple!( + idxTypes!(Key, fullBits - bitSizeOf!(Prefix[$-1]), Prefix[0..$-1]), + BitPacked!(typeof(Prefix[$-2](Key.init)), fullBits - bitSizeOf!(Prefix[$-1])) + ); } } @@ -4815,7 +4818,7 @@ else @trusted bool loadProperty(Set=CodepointSet, C) (in C[] name, ref Set target) { - alias comparePropertyName ucmp; + alias ucmp = comparePropertyName; // conjure cumulative properties by hand if(ucmp(name, "L") == 0 || ucmp(name, "Letter") == 0) { @@ -5194,9 +5197,9 @@ template genericDecodeGrapheme(bool getValue) alias graphemeExtend = graphemeExtendTrie; alias spacingMark = mcTrie; static if(getValue) - alias Grapheme Value; + alias Value = Grapheme; else - alias void Value; + alias Value = void; Value genericDecodeGrapheme(Input)(ref Input range) { diff --git a/std/uuid.d b/std/uuid.d index 0d68f7686..b05f625f0 100644 --- a/std/uuid.d +++ b/std/uuid.d @@ -1316,8 +1316,8 @@ UUID parseUUID(Range)(ref Range uuidRange) if(isInputRange!Range } } } - alias TestRange!false TestInputRange; - alias TestRange!true TestForwardRange; + alias TestInputRange = TestRange!false; + alias TestForwardRange = TestRange!true; assert(isInputRange!TestInputRange); assert(is(ElementType!TestInputRange == dchar)); diff --git a/std/variant.d b/std/variant.d index 38d879123..90ba7bd36 100644 --- a/std/variant.d +++ b/std/variant.d @@ -91,38 +91,42 @@ struct This; template AssociativeArray(T) { enum bool valid = false; - alias void Key; - alias void Value; + alias Key = void; + alias Value = void; } template AssociativeArray(T : V[K], K, V) { enum bool valid = true; - alias K Key; - alias V Value; + alias Key = K; + alias Value = V; } template This2Variant(V, T...) { - static if (T.length == 0) alias TypeTuple!() This2Variant; + static if (T.length == 0) + alias This2Variant = TypeTuple!(); else static if (is(AssociativeArray!(T[0]).Key == This)) { static if (is(AssociativeArray!(T[0]).Value == This)) - alias TypeTuple!(V[V], - This2Variant!(V, T[1 .. $])) This2Variant; + alias This2Variant = + TypeTuple!(V[V], + This2Variant!(V, T[1 .. $])); else - alias TypeTuple!(AssociativeArray!(T[0]).Value[V], - This2Variant!(V, T[1 .. $])) This2Variant; + alias This2Variant = + TypeTuple!(AssociativeArray!(T[0]).Value[V], + This2Variant!(V, T[1 .. $])); } else static if (is(AssociativeArray!(T[0]).Value == This)) - alias TypeTuple!(V[AssociativeArray!(T[0]).Key], - This2Variant!(V, T[1 .. $])) This2Variant; + alias This2Variant = + TypeTuple!(V[AssociativeArray!(T[0]).Key], + This2Variant!(V, T[1 .. $])); else static if (is(T[0] == This[])) - alias TypeTuple!(V[], This2Variant!(V, T[1 .. $])) This2Variant; + alias This2Variant = TypeTuple!(V[], This2Variant!(V, T[1 .. $])); else static if (is(T[0] == This*)) - alias TypeTuple!(V*, This2Variant!(V, T[1 .. $])) This2Variant; + alias This2Variant = TypeTuple!(V*, This2Variant!(V, T[1 .. $])); else - alias TypeTuple!(T[0], This2Variant!(V, T[1 .. $])) This2Variant; + alias This2Variant = TypeTuple!(T[0], This2Variant!(V, T[1 .. $])); } /** @@ -153,7 +157,7 @@ template This2Variant(V, T...) struct VariantN(size_t maxDataSize, AllowedTypesX...) { - alias This2Variant!(VariantN, AllowedTypesX) AllowedTypes; + alias AllowedTypes = This2Variant!(VariantN, AllowedTypesX); private: // Compute the largest practical size from maxDataSize @@ -475,7 +479,7 @@ private: { // array type; parm is the element to append auto arg = cast(VariantN*) parm; - alias typeof((*zis)[0]) E; + alias E = typeof((*zis)[0]); if (arg[0].convertsTo!(E)) { // append one element to the array @@ -706,11 +710,11 @@ public: // { // static if (isStaticArray!(T)) // { - // alias typeof(testing123(&T[0])) DecayStaticToDynamicArray; + // alias DecayStaticToDynamicArray = typeof(testing123(&T[0])); // } // else // { - // alias T DecayStaticToDynamicArray; + // alias DecayStaticToDynamicArray = T; // } // } @@ -839,7 +843,7 @@ public: bool opEquals(T)(auto ref T rhs) const { static if (is(Unqual!T == VariantN)) - alias rhs temp; + alias temp = rhs; else auto temp = VariantN(rhs); return !fptr(OpID.compare, cast(ubyte[size]*) &store, @@ -861,7 +865,7 @@ public: int opCmp(T)(T rhs) { static if (is(T == VariantN)) - alias rhs temp; + alias temp = rhs; else auto temp = VariantN(rhs); auto result = fptr(OpID.compare, &store, &temp); @@ -1129,7 +1133,7 @@ public: */ int opApply(Delegate)(scope Delegate dg) if (is(Delegate == delegate)) { - alias ParameterTypeTuple!(Delegate)[0] A; + alias A = ParameterTypeTuple!(Delegate)[0]; if (type == typeid(A[])) { auto arr = get!(A[]); @@ -1185,8 +1189,8 @@ unittest } static assert(S.sizeof >= Variant.sizeof); - alias TypeTuple!(string, int, S) Types; - alias VariantN!(maxSize!Types, Types) MyVariant; + alias Types = TypeTuple!(string, int, S); + alias MyVariant = VariantN!(maxSize!Types, Types); auto v = MyVariant(S.init); assert(v == S.init); @@ -1233,7 +1237,7 @@ unittest template Algebraic(T...) { - alias VariantN!(maxSize!(T), T) Algebraic; + alias Algebraic = VariantN!(maxSize!(T), T); } /** @@ -1246,7 +1250,7 @@ $(D_PARAM VariantN) directly with a different maximum size either for storing larger types, or for saving memory. */ -alias VariantN!(maxSize!(creal, char[], void delegate())) Variant; +alias Variant = VariantN!(maxSize!(creal, char[], void delegate())); /** * Returns an array of variants constructed from $(D_PARAM args). @@ -1325,18 +1329,18 @@ static class VariantException : Exception unittest { - alias This2Variant!(char, int, This[int]) W1; - alias TypeTuple!(int, char[int]) W2; + alias W1 = This2Variant!(char, int, This[int]); + alias W2 = TypeTuple!(int, char[int]); static assert(is(W1 == W2)); - alias Algebraic!(void, string) var_t; + alias var_t = Algebraic!(void, string); var_t foo = "quux"; } unittest { // @@@BUG@@@ - // alias Algebraic!(real, This[], This[int], This[This]) A; + // alias A = Algebraic!(real, This[], This[int], This[This]); // A v1, v2, v3; // v2 = 5.0L; // v3 = 42.0L; @@ -1901,7 +1905,7 @@ unittest private auto visitImpl(bool Strict, VariantType, Handler...)(VariantType variant) if (isAlgebraic!VariantType && Handler.length > 0) { - alias VariantType.AllowedTypes AllowedTypes; + alias AllowedTypes = VariantType.AllowedTypes; /** @@ -1929,7 +1933,7 @@ private auto visitImpl(bool Strict, VariantType, Handler...)(VariantType variant // Handle normal function objects static if (isSomeFunction!dg) { - alias ParameterTypeTuple!dg Params; + alias Params = ParameterTypeTuple!dg; static if (Params.length == 0) { // Just check exception functions in the first diff --git a/std/xml.d b/std/xml.d index c0683bfbb..b23585270 100644 --- a/std/xml.d +++ b/std/xml.d @@ -1696,9 +1696,9 @@ class DocumentParser : ElementParser */ class ElementParser { - alias void delegate(string) Handler; - alias void delegate(in Element element) ElementHandler; - alias void delegate(ElementParser parser) ParserHandler; + alias Handler = void delegate(string); + alias ElementHandler = void delegate(in Element element); + alias ParserHandler = void delegate(ElementParser parser); private { @@ -2821,7 +2821,7 @@ class CheckException : XMLException } } -private alias CheckException Err; +private alias Err = CheckException; // Private helper functions