Update compiler, remove deprecated modules
This commit is contained in:
parent
048939410c
commit
c68b8d1bdd
@ -7,11 +7,11 @@ os:
|
||||
language: d
|
||||
|
||||
d:
|
||||
- dmd-2.087.1
|
||||
- dmd-2.091.1
|
||||
|
||||
env:
|
||||
global:
|
||||
- LATEST=2.087.1
|
||||
- LATEST=2.091.1
|
||||
|
||||
matrix:
|
||||
- ARCH=x86_64
|
||||
|
@ -174,7 +174,7 @@ parameter is used)
|
||||
|
||||
| DMD | GCC |
|
||||
|:-------:|:---------:|
|
||||
| 2.087.1 | gdc trunk |
|
||||
| 2.091.1 | gdc trunk |
|
||||
|
||||
## Further characteristics
|
||||
|
||||
|
@ -4,10 +4,10 @@ os: Visual Studio 2015
|
||||
environment:
|
||||
matrix:
|
||||
- DC: dmd
|
||||
DVersion: 2.087.1
|
||||
DVersion: 2.091.1
|
||||
arch: x64
|
||||
- DC: dmd
|
||||
DVersion: 2.087.1
|
||||
DVersion: 2.091.1
|
||||
arch: x86
|
||||
|
||||
skip_tags: true
|
||||
|
@ -43,14 +43,14 @@ import tanya.meta.trait;
|
||||
*/
|
||||
template Unqual(T)
|
||||
{
|
||||
static if (is(T U == const U)
|
||||
static if (is(T U == shared const U)
|
||||
|| is(T U == shared inout U)
|
||||
|| is(T U == shared inout const U)
|
||||
|| is(T U == inout const U)
|
||||
|| is(T U == const U)
|
||||
|| is(T U == immutable U)
|
||||
|| is(T U == inout U)
|
||||
|| is(T U == inout const U)
|
||||
|| is(T U == shared U)
|
||||
|| is(T U == shared const U)
|
||||
|| is(T U == shared inout U)
|
||||
|| is(T U == shared inout const U))
|
||||
|| is(T U == shared U))
|
||||
{
|
||||
alias Unqual = U;
|
||||
}
|
||||
@ -138,8 +138,6 @@ template OriginalType(T)
|
||||
* To = Target type.
|
||||
*
|
||||
* Returns: $(D_PARAM To) with the constness of $(D_PARAM From).
|
||||
*
|
||||
* See_Also: $(D_PSYMBOL CopyTypeQualifiers).
|
||||
*/
|
||||
template CopyConstness(From, To)
|
||||
{
|
||||
@ -185,187 +183,6 @@ template CopyConstness(From, To)
|
||||
static assert(is(CopyConstness!(immutable int, const char) == immutable char));
|
||||
}
|
||||
|
||||
/**
|
||||
* Copies type qualifiers of $(D_PARAM From) to $(D_PARAM To).
|
||||
*
|
||||
* Type qualifiers copied are:
|
||||
* $(UL
|
||||
* $(LI const)
|
||||
* $(LI immutable)
|
||||
* $(LI inout)
|
||||
* $(LI shared)
|
||||
* )
|
||||
* and combinations of these.
|
||||
*
|
||||
* Params:
|
||||
* From = Source type.
|
||||
* To = Target type.
|
||||
*
|
||||
* Returns: $(D_PARAM To) with the type qualifiers of $(D_PARAM From).
|
||||
*
|
||||
* See_Also: $(D_PSYMBOL CopyConstness).
|
||||
*/
|
||||
template CopyTypeQualifiers(From, To)
|
||||
{
|
||||
static if (is(From T == immutable T))
|
||||
{
|
||||
alias CopyTypeQualifiers = immutable To;
|
||||
}
|
||||
else static if (is(From T == const T))
|
||||
{
|
||||
alias CopyTypeQualifiers = const To;
|
||||
}
|
||||
else static if (is(From T == shared T))
|
||||
{
|
||||
alias CopyTypeQualifiers = shared To;
|
||||
}
|
||||
else static if (is(From T == shared const T))
|
||||
{
|
||||
alias CopyTypeQualifiers = shared const To;
|
||||
}
|
||||
else static if (is(From T == inout T))
|
||||
{
|
||||
alias CopyTypeQualifiers = inout To;
|
||||
}
|
||||
else static if (is(From T == shared inout T))
|
||||
{
|
||||
alias CopyTypeQualifiers = shared inout To;
|
||||
}
|
||||
else static if (is(From T == inout const T))
|
||||
{
|
||||
alias CopyTypeQualifiers = inout const To;
|
||||
}
|
||||
else static if (is(From T == shared inout const T))
|
||||
{
|
||||
alias CopyTypeQualifiers = shared inout const To;
|
||||
}
|
||||
else
|
||||
{
|
||||
alias CopyTypeQualifiers = To;
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
@nogc nothrow pure @safe unittest
|
||||
{
|
||||
static assert(is(CopyTypeQualifiers!(int, char) == char));
|
||||
static assert(is(CopyTypeQualifiers!(const int, char) == const char));
|
||||
static assert(is(CopyTypeQualifiers!(immutable int, char) == immutable char));
|
||||
static assert(is(CopyTypeQualifiers!(inout int, char) == inout char));
|
||||
static assert(is(CopyTypeQualifiers!(inout const int, char) == inout const char));
|
||||
|
||||
static assert(is(CopyTypeQualifiers!(shared int, char) == shared char));
|
||||
static assert(is(CopyTypeQualifiers!(shared const int, char) == shared const char));
|
||||
static assert(is(CopyTypeQualifiers!(shared inout int, char) == shared inout char));
|
||||
static assert(is(CopyTypeQualifiers!(shared inout const int, char) == shared inout const char));
|
||||
}
|
||||
|
||||
/**
|
||||
* Evaluates to the unsigned counterpart of the integral type $(D_PARAM T) preserving all type qualifiers.
|
||||
* If $(D_PARAM T) is already unsigned, $(D_INLINECODE Unsigned!T) aliases $(D_PARAM T).
|
||||
*
|
||||
* Params:
|
||||
* T = A type.
|
||||
*
|
||||
* Returns: Unsigned counterpart of $(D_PARAM T).
|
||||
*
|
||||
* See_Also: $(D_PSYMBOL isSigned).
|
||||
*/
|
||||
template Unsigned(T)
|
||||
if (isIntegral!T)
|
||||
{
|
||||
alias UnqualedType = Unqual!(OriginalType!T);
|
||||
static if (is(UnqualedType == byte))
|
||||
{
|
||||
alias Unsigned = CopyTypeQualifiers!(T, ubyte);
|
||||
}
|
||||
else static if (is(UnqualedType == short))
|
||||
{
|
||||
alias Unsigned = CopyTypeQualifiers!(T, ushort);
|
||||
}
|
||||
else static if (is(UnqualedType == int))
|
||||
{
|
||||
alias Unsigned = CopyTypeQualifiers!(T, uint);
|
||||
}
|
||||
else static if (is(UnqualedType == long))
|
||||
{
|
||||
alias Unsigned = CopyTypeQualifiers!(T, ulong);
|
||||
}
|
||||
else
|
||||
{
|
||||
alias Unsigned = T;
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
@nogc nothrow pure @safe unittest
|
||||
{
|
||||
static assert(is(Unsigned!byte == ubyte));
|
||||
static assert(is(Unsigned!short == ushort));
|
||||
static assert(is(Unsigned!int == uint));
|
||||
static assert(is(Unsigned!long == ulong));
|
||||
|
||||
static assert(is(Unsigned!(const byte) == const ubyte));
|
||||
static assert(is(Unsigned!(shared byte) == shared ubyte));
|
||||
static assert(is(Unsigned!(shared const byte) == shared const ubyte));
|
||||
|
||||
static assert(!is(Unsigned!float));
|
||||
static assert(is(Unsigned!ubyte == ubyte));
|
||||
}
|
||||
|
||||
/**
|
||||
* Evaluates to the signed counterpart of the integral type $(D_PARAM T) preserving all type qualifiers.
|
||||
* If $(D_PARAM T) is already signed, $(D_INLINECODE Signed!T) aliases $(D_PARAM T).
|
||||
*
|
||||
* Params:
|
||||
* T = A type.
|
||||
*
|
||||
* Returns: Signed counterpart of $(D_PARAM T).
|
||||
*
|
||||
* See_Also: $(D_PSYMBOL isUnsigned).
|
||||
*/
|
||||
template Signed(T)
|
||||
if (isIntegral!T)
|
||||
{
|
||||
alias UnqualedType = Unqual!(OriginalType!T);
|
||||
static if (is(UnqualedType == ubyte))
|
||||
{
|
||||
alias Signed = CopyTypeQualifiers!(T, byte);
|
||||
}
|
||||
else static if (is(UnqualedType == ushort))
|
||||
{
|
||||
alias Signed = CopyTypeQualifiers!(T, short);
|
||||
}
|
||||
else static if (is(UnqualedType == uint))
|
||||
{
|
||||
alias Signed = CopyTypeQualifiers!(T, int);
|
||||
}
|
||||
else static if (is(UnqualedType == ulong))
|
||||
{
|
||||
alias Signed = CopyTypeQualifiers!(T, long);
|
||||
}
|
||||
else
|
||||
{
|
||||
alias Signed = T;
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
@nogc nothrow pure @safe unittest
|
||||
{
|
||||
static assert(is(Signed!ubyte == byte));
|
||||
static assert(is(Signed!ushort == short));
|
||||
static assert(is(Signed!uint == int));
|
||||
static assert(is(Signed!ulong == long));
|
||||
|
||||
static assert(is(Signed!(const ubyte) == const byte));
|
||||
static assert(is(Signed!(shared ubyte) == shared byte));
|
||||
static assert(is(Signed!(shared const ubyte) == shared const byte));
|
||||
|
||||
static assert(!is(Signed!float));
|
||||
static assert(is(Signed!byte == byte));
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the target type `U` of a pointer `U*`.
|
||||
*
|
||||
@ -445,37 +262,6 @@ template ValueType(T)
|
||||
static assert(!is(ValueType!(int[15])));
|
||||
}
|
||||
|
||||
/**
|
||||
* Params:
|
||||
* T = Scalar type.
|
||||
*
|
||||
* Returns: The type $(D_PARAM T) will promote to.
|
||||
*
|
||||
* See_Also: $(LINK2 https://dlang.org/spec/type.html#integer-promotions,
|
||||
* Integer Promotions).
|
||||
*/
|
||||
template Promoted(T)
|
||||
if (isScalarType!T)
|
||||
{
|
||||
alias Promoted = CopyTypeQualifiers!(T, typeof(T.init + T.init));
|
||||
}
|
||||
|
||||
///
|
||||
@nogc nothrow pure @safe unittest
|
||||
{
|
||||
static assert(is(Promoted!bool == int));
|
||||
static assert(is(Promoted!byte == int));
|
||||
static assert(is(Promoted!ubyte == int));
|
||||
static assert(is(Promoted!short == int));
|
||||
static assert(is(Promoted!ushort == int));
|
||||
static assert(is(Promoted!char == int));
|
||||
static assert(is(Promoted!wchar == int));
|
||||
static assert(is(Promoted!dchar == uint));
|
||||
|
||||
static assert(is(Promoted!(const bool) == const int));
|
||||
static assert(is(Promoted!(shared bool) == shared int));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds $(D_KEYWORD inout) qualifier to the type $(D_PARAM T).
|
||||
*
|
||||
@ -604,86 +390,6 @@ alias SharedInoutConstOf(T) = shared(inout const T);
|
||||
static assert(is(SharedInoutConstOf!int == shared inout const int));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a template with one argument which applies all qualifiers of
|
||||
* $(D_PARAM T) on its argument if instantiated.
|
||||
*
|
||||
* Params:
|
||||
* T = A type.
|
||||
*
|
||||
* Returns: $(D_INLINECODE shared(inout const T)).
|
||||
*/
|
||||
template QualifierOf(T)
|
||||
{
|
||||
static if (is(T U == const U))
|
||||
{
|
||||
alias QualifierOf = ConstOf;
|
||||
}
|
||||
else static if (is(T U == immutable U))
|
||||
{
|
||||
alias QualifierOf = ImmutableOf;
|
||||
}
|
||||
else static if (is(T U == inout U))
|
||||
{
|
||||
alias QualifierOf = InoutOf;
|
||||
}
|
||||
else static if (is(T U == inout const U))
|
||||
{
|
||||
alias QualifierOf = InoutConstOf;
|
||||
}
|
||||
else static if (is(T U == shared U))
|
||||
{
|
||||
alias QualifierOf = SharedOf;
|
||||
}
|
||||
else static if (is(T U == shared const U))
|
||||
{
|
||||
alias QualifierOf = SharedConstOf;
|
||||
}
|
||||
else static if (is(T U == shared inout U))
|
||||
{
|
||||
alias QualifierOf = SharedInoutOf;
|
||||
}
|
||||
else static if (is(T U == shared inout const U))
|
||||
{
|
||||
alias QualifierOf = SharedInoutConstOf;
|
||||
}
|
||||
else
|
||||
{
|
||||
alias QualifierOf(T) = T;
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
@nogc nothrow pure @safe unittest
|
||||
{
|
||||
alias MutableOf = QualifierOf!int;
|
||||
static assert(is(MutableOf!uint == uint));
|
||||
|
||||
alias ConstOf = QualifierOf!(const int);
|
||||
static assert(is(ConstOf!uint == const uint));
|
||||
|
||||
alias InoutOf = QualifierOf!(inout int);
|
||||
static assert(is(InoutOf!uint == inout uint));
|
||||
|
||||
alias InoutConstOf = QualifierOf!(inout const int);
|
||||
static assert(is(InoutConstOf!uint == inout const uint));
|
||||
|
||||
alias ImmutableOf = QualifierOf!(immutable int);
|
||||
static assert(is(ImmutableOf!uint == immutable uint));
|
||||
|
||||
alias SharedOf = QualifierOf!(shared int);
|
||||
static assert(is(SharedOf!uint == shared uint));
|
||||
|
||||
alias SharedConstOf = QualifierOf!(shared const int);
|
||||
static assert(is(SharedConstOf!uint == shared const uint));
|
||||
|
||||
alias SharedInoutOf = QualifierOf!(shared inout int);
|
||||
static assert(is(SharedInoutOf!uint == shared inout uint));
|
||||
|
||||
alias SharedInoutConstOf = QualifierOf!(shared inout const int);
|
||||
static assert(is(SharedInoutConstOf!uint == shared inout const uint));
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the type of $(D_PARAM T). If $(D_PARAM T) is already a type,
|
||||
* $(D_PSYMBOL TypeOf) aliases itself to $(D_PARAM T).
|
||||
@ -719,142 +425,6 @@ if (isExpressions!T || __traits(isTemplate, T))
|
||||
static assert(!is(TypeOf!(tanya.meta)));
|
||||
}
|
||||
|
||||
// e.g. returns int for int**.
|
||||
private template FinalPointerTarget(T)
|
||||
{
|
||||
static if (isPointer!T)
|
||||
{
|
||||
alias FinalPointerTarget = FinalPointerTarget!(PointerTarget!T);
|
||||
}
|
||||
else
|
||||
{
|
||||
alias FinalPointerTarget = T;
|
||||
}
|
||||
}
|
||||
|
||||
// Returns true if T1 is void* and T2 is some pointer.
|
||||
private template voidAndPointer(T1, T2)
|
||||
{
|
||||
enum bool voidAndPointer = is(Unqual!(PointerTarget!T1) == void)
|
||||
&& isPointer!T2;
|
||||
}
|
||||
|
||||
// Type returned by the ternary operator.
|
||||
private alias TernaryType(T, U) = typeof(true ? T.init : U.init);
|
||||
|
||||
/**
|
||||
* Determines the type all $(D_PARAM Args) can be implicitly converted to.
|
||||
*
|
||||
* $(OL
|
||||
* $(LI If one of the arguments is $(D_KEYWORD void), the common type is
|
||||
* $(D_KEYWORD void).)
|
||||
* $(LI The common type of integers with the same sign is the type with a
|
||||
* larger size. Signed and unsigned integers don't have a common type.
|
||||
* Type qualifiers are only preserved if all arguments are the same
|
||||
* type.)
|
||||
* $(LI The common type of floating point numbers is the type with more
|
||||
* precision. Type qualifiers are only preserved if all arguments are
|
||||
* the same type.)
|
||||
* $(LI The common type of polymorphic objects is the next, more generic type
|
||||
* both objects inherit from, e.g. $(D_PSYMBOL Object).)
|
||||
* $(LI `void*` is concerned as a common type of pointers only if one of the
|
||||
* arguments is a void pointer.)
|
||||
* $(LI Other types have a common type only if their pointers have a common
|
||||
* type. It means that for example $(D_KEYWORD bool) and $(D_KEYWORD int)
|
||||
don't have a common type. If the types fullfill this condition, the
|
||||
common type is determined with the ternary operator, i.e.
|
||||
`typeof(true ? T1.init : T2.init)` is evaluated.)
|
||||
* )
|
||||
*
|
||||
* If $(D_PARAM Args) don't have a common type, $(D_PSYMBOL CommonType) is
|
||||
* $(D_KEYWORD void).
|
||||
*
|
||||
* Params:
|
||||
* Args = Type list.
|
||||
*
|
||||
* Returns: Common type for $(D_PARAM Args) or $(D_KEYWORD void) if
|
||||
* $(D_PARAM Args) don't have a common type.
|
||||
*/
|
||||
template CommonType(Args...)
|
||||
if (allSatisfy!(isType, Args))
|
||||
{
|
||||
static if (Args.length == 0
|
||||
|| is(Unqual!(Args[0]) == void)
|
||||
|| is(Unqual!(Args[1]) == void))
|
||||
{
|
||||
alias CommonType = void;
|
||||
}
|
||||
else static if (Args.length == 1)
|
||||
{
|
||||
alias CommonType = Args[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
private alias Pair = Args[0 .. 2];
|
||||
private enum bool sameSigned = allSatisfy!(isIntegral, Pair)
|
||||
&& isSigned!(Args[0]) == isSigned!(Args[1]);
|
||||
|
||||
static if (is(Args[0] == Args[1]))
|
||||
{
|
||||
alias CommonType = CommonType!(Args[0], Args[2 .. $]);
|
||||
}
|
||||
else static if (sameSigned || allSatisfy!(isFloatingPoint, Pair))
|
||||
{
|
||||
alias CommonType = CommonType!(Unqual!(Largest!Pair),
|
||||
Args[2 .. $]);
|
||||
}
|
||||
else static if (voidAndPointer!Pair
|
||||
|| voidAndPointer!(Args[1], Args[0]))
|
||||
{
|
||||
// Workaround for https://issues.dlang.org/show_bug.cgi?id=15557.
|
||||
// Determine the qualifiers returned by the ternary operator as if
|
||||
// both pointers were int*. Then copy the qualifiers to void*.
|
||||
alias P1 = CopyTypeQualifiers!(FinalPointerTarget!(Args[0]), int)*;
|
||||
alias P2 = CopyTypeQualifiers!(FinalPointerTarget!(Args[1]), int)*;
|
||||
static if (is(TernaryType!(P1, P2) U))
|
||||
{
|
||||
alias CommonType = CopyTypeQualifiers!(PointerTarget!U, void)*;
|
||||
}
|
||||
else
|
||||
{
|
||||
alias CommonType = void;
|
||||
}
|
||||
}
|
||||
else static if ((isPointer!(Args[0]) || isPolymorphicType!(Args[0]))
|
||||
&& is(TernaryType!Pair U))
|
||||
{
|
||||
alias CommonType = CommonType!(U, Args[2 .. $]);
|
||||
}
|
||||
else static if (is(TernaryType!(Args[0]*, Args[1]*)))
|
||||
{
|
||||
alias CommonType = CommonType!(TernaryType!Pair, Args[2 .. $]);
|
||||
}
|
||||
else
|
||||
{
|
||||
alias CommonType = void;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
@nogc nothrow pure @safe unittest
|
||||
{
|
||||
static assert(is(CommonType!(int, int, int) == int));
|
||||
static assert(is(CommonType!(ubyte, ushort, uint) == uint));
|
||||
static assert(is(CommonType!(int, uint) == void));
|
||||
|
||||
static assert(is(CommonType!(int, const int) == int));
|
||||
static assert(is(CommonType!(const int, const int) == const int));
|
||||
|
||||
static assert(is(CommonType!(int[], const(int)[]) == const(int)[]));
|
||||
static assert(is(CommonType!(string, char[]) == const(char)[]));
|
||||
|
||||
class A
|
||||
{
|
||||
}
|
||||
static assert(is(CommonType!(const A, Object) == const Object));
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the type with the smallest size in the $(D_PARAM Args) list. If
|
||||
* several types have the same type, the leftmost is returned.
|
||||
|
@ -14,6 +14,7 @@
|
||||
*/
|
||||
module tanya.algorithm.comparison;
|
||||
|
||||
import std.traits : CommonType;
|
||||
import tanya.algorithm.mutation;
|
||||
import tanya.math;
|
||||
static import tanya.memory.op;
|
||||
|
@ -14,6 +14,7 @@
|
||||
*/
|
||||
module tanya.conv;
|
||||
|
||||
import std.traits : Unsigned;
|
||||
import tanya.container.string;
|
||||
import tanya.memory.allocator;
|
||||
deprecated("Use tanya.memory.lifetime.emplace instead")
|
||||
|
@ -1,16 +0,0 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
/*
|
||||
* Copyright: Eugene Wissner 2017-2019.
|
||||
* License: $(LINK2 https://www.mozilla.org/en-US/MPL/2.0/,
|
||||
* Mozilla Public License, v. 2.0).
|
||||
* Authors: $(LINK2 mailto:info@caraus.de, Eugene Wissner)
|
||||
* Source: $(LINK2 https://github.com/caraus-ecms/tanya/blob/master/source/tanya/exception.d,
|
||||
* tanya/exception.d)
|
||||
*/
|
||||
deprecated("Use tanya.memory.allocator instead")
|
||||
module tanya.exception;
|
||||
|
||||
public import tanya.memory.allocator : onOutOfMemoryError, OutOfMemoryError;
|
@ -1,18 +0,0 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
/*
|
||||
* Functions that manipulate other functions and their argument lists.
|
||||
*
|
||||
* Copyright: Eugene Wissner 2018-2019.
|
||||
* License: $(LINK2 https://www.mozilla.org/en-US/MPL/2.0/,
|
||||
* Mozilla Public License, v. 2.0).
|
||||
* Authors: $(LINK2 mailto:info@caraus.de, Eugene Wissner)
|
||||
* Source: $(LINK2 https://github.com/caraus-ecms/tanya/blob/master/source/tanya/functional.d,
|
||||
* tanya/functional.d)
|
||||
*/
|
||||
deprecated("Use tanya.memory.lifetime instead")
|
||||
module tanya.functional;
|
||||
|
||||
public import tanya.memory.lifetime : forward;
|
File diff suppressed because it is too large
Load Diff
@ -14,7 +14,6 @@
|
||||
*/
|
||||
module tanya.math.nbtheory;
|
||||
|
||||
import tanya.math.mp;
|
||||
import tanya.meta.trait;
|
||||
import tanya.meta.transform;
|
||||
|
||||
@ -91,21 +90,6 @@ if (isFloatingPoint!T)
|
||||
static assert(is(typeof(r.abs) == real));
|
||||
}
|
||||
|
||||
/// ditto
|
||||
T abs(T : Integer)(const auto ref T x)
|
||||
{
|
||||
auto result = Integer(x, x.allocator);
|
||||
result.sign = Sign.positive;
|
||||
return result;
|
||||
}
|
||||
|
||||
/// ditto
|
||||
T abs(T : Integer)(T x)
|
||||
{
|
||||
x.sign = Sign.positive;
|
||||
return x;
|
||||
}
|
||||
|
||||
version (D_Ddoc)
|
||||
{
|
||||
/**
|
||||
|
@ -21,7 +21,6 @@
|
||||
*/
|
||||
module tanya.math;
|
||||
|
||||
import tanya.math.mp;
|
||||
import tanya.math.nbtheory;
|
||||
import tanya.meta.trait;
|
||||
import tanya.meta.transform;
|
||||
@ -548,9 +547,6 @@ if (isFloatingPoint!F)
|
||||
/**
|
||||
* Computes $(D_PARAM x) to the power $(D_PARAM y) modulo $(D_PARAM z).
|
||||
*
|
||||
* If $(D_PARAM I) is an $(D_PSYMBOL Integer), the allocator of $(D_PARAM x)
|
||||
* is used to allocate the result.
|
||||
*
|
||||
* Params:
|
||||
* I = Base type.
|
||||
* G = Exponent type.
|
||||
@ -600,41 +596,6 @@ in (z > 0, "Division by zero")
|
||||
return result;
|
||||
}
|
||||
|
||||
/// ditto
|
||||
I pow(I)(const auto ref I x, const auto ref I y, const auto ref I z)
|
||||
if (is(I == Integer))
|
||||
in (z.length > 0, "Division by zero")
|
||||
{
|
||||
size_t i;
|
||||
auto tmp1 = Integer(x, x.allocator);
|
||||
auto result = Integer(x.allocator);
|
||||
|
||||
if (x.size == 0 && y.size != 0)
|
||||
{
|
||||
i = y.size;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = 1;
|
||||
}
|
||||
while (i < y.size)
|
||||
{
|
||||
for (uint mask = 0x01; mask != 0x10000000; mask <<= 1)
|
||||
{
|
||||
if (y.rep[i] & mask)
|
||||
{
|
||||
result *= tmp1;
|
||||
result %= z;
|
||||
}
|
||||
auto tmp2 = tmp1;
|
||||
tmp1 *= tmp2;
|
||||
tmp1 %= z;
|
||||
}
|
||||
++i;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
///
|
||||
@nogc nothrow pure @safe unittest
|
||||
{
|
||||
@ -648,32 +609,3 @@ in (z.length > 0, "Division by zero")
|
||||
assert(pow(0, 0, 5) == 1);
|
||||
assert(pow(0, 5, 5) == 0);
|
||||
}
|
||||
|
||||
///
|
||||
@nogc nothrow pure @safe unittest
|
||||
{
|
||||
assert(pow(Integer(3), Integer(5), Integer(7)) == 5);
|
||||
assert(pow(Integer(2), Integer(2), Integer(1)) == 0);
|
||||
assert(pow(Integer(3), Integer(3), Integer(3)) == 0);
|
||||
assert(pow(Integer(7), Integer(4), Integer(2)) == 1);
|
||||
assert(pow(Integer(53), Integer(0), Integer(2)) == 1);
|
||||
assert(pow(Integer(53), Integer(1), Integer(3)) == 2);
|
||||
assert(pow(Integer(53), Integer(2), Integer(5)) == 4);
|
||||
assert(pow(Integer(0), Integer(0), Integer(5)) == 1);
|
||||
assert(pow(Integer(0), Integer(5), Integer(5)) == 0);
|
||||
}
|
||||
|
||||
deprecated
|
||||
bool isPseudoprime(ulong x) @nogc nothrow pure @safe
|
||||
{
|
||||
return pow(2, x - 1, x) == 1;
|
||||
}
|
||||
|
||||
///
|
||||
@nogc nothrow pure @safe unittest
|
||||
{
|
||||
assert(74623.isPseudoprime);
|
||||
assert(104729.isPseudoprime);
|
||||
assert(15485867.isPseudoprime);
|
||||
assert(!15485868.isPseudoprime);
|
||||
}
|
||||
|
@ -1,73 +0,0 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
module tanya.math.tests.mp;
|
||||
|
||||
import tanya.algorithm.comparison;
|
||||
import tanya.math.mp;
|
||||
|
||||
@nogc nothrow pure @safe unittest
|
||||
{
|
||||
auto h1 = Integer(18);
|
||||
auto h2 = Integer(4);
|
||||
h1 %= h2;
|
||||
assert(h1 == 2);
|
||||
|
||||
h1 = 8;
|
||||
h1 %= h2;
|
||||
assert(h1 == 0);
|
||||
|
||||
h1 = 7;
|
||||
h1 %= h2;
|
||||
assert(h1 == 3);
|
||||
|
||||
h1 = 56088;
|
||||
h2 = 456;
|
||||
h1 /= h2;
|
||||
assert(h1 == 123);
|
||||
}
|
||||
|
||||
@nogc nothrow pure @safe unittest
|
||||
{
|
||||
Integer integer;
|
||||
assert(integer.toArray().length == 0);
|
||||
}
|
||||
|
||||
@nogc nothrow pure @safe unittest
|
||||
{
|
||||
auto integer = Integer(0x03);
|
||||
ubyte[1] expected = [ 0x03 ];
|
||||
|
||||
auto array = integer.toArray();
|
||||
assert(equal(array[], expected[]));
|
||||
}
|
||||
|
||||
@nogc nothrow pure @safe unittest
|
||||
{
|
||||
ubyte[63] expected = [
|
||||
0x02, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
|
||||
0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
|
||||
0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,
|
||||
0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20,
|
||||
0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28,
|
||||
0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30,
|
||||
0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38,
|
||||
0x39, 0x3a, 0x3b, 0x00, 0x61, 0x62, 0x63,
|
||||
];
|
||||
auto integer = Integer(Sign.positive, expected[]);
|
||||
|
||||
auto array = integer.toArray();
|
||||
assert(equal(array[], expected[]));
|
||||
}
|
||||
|
||||
@nogc nothrow pure @safe unittest
|
||||
{
|
||||
ubyte[14] expected = [
|
||||
0x22, 0x33, 0x44, 0x55, 0x05, 0x06, 0x07,
|
||||
0x08, 0x3a, 0x3b, 0x00, 0x61, 0x62, 0x63,
|
||||
];
|
||||
auto integer = Integer(Sign.positive, expected[]);
|
||||
|
||||
auto array = integer.toArray();
|
||||
assert(equal(array[], expected[]));
|
||||
}
|
@ -17,33 +17,3 @@ static if (ieeePrecision!float == IEEEPrecision.doubleExtended)
|
||||
unnormal.mantissa = 0x1;
|
||||
assert(classify(unnormal) == FloatingPointClass.subnormal);
|
||||
}
|
||||
|
||||
@nogc nothrow pure @safe unittest
|
||||
{
|
||||
assert(74653.isPseudoprime);
|
||||
assert(74687.isPseudoprime);
|
||||
assert(74699.isPseudoprime);
|
||||
assert(74707.isPseudoprime);
|
||||
assert(74713.isPseudoprime);
|
||||
assert(74717.isPseudoprime);
|
||||
assert(74719.isPseudoprime);
|
||||
assert(74747.isPseudoprime);
|
||||
assert(74759.isPseudoprime);
|
||||
assert(74761.isPseudoprime);
|
||||
assert(74771.isPseudoprime);
|
||||
assert(74779.isPseudoprime);
|
||||
assert(74797.isPseudoprime);
|
||||
assert(74821.isPseudoprime);
|
||||
assert(74827.isPseudoprime);
|
||||
assert(9973.isPseudoprime);
|
||||
assert(49979693.isPseudoprime);
|
||||
assert(104395303.isPseudoprime);
|
||||
assert(593441861.isPseudoprime);
|
||||
assert(104729.isPseudoprime);
|
||||
assert(15485867.isPseudoprime);
|
||||
assert(49979693.isPseudoprime);
|
||||
assert(104395303.isPseudoprime);
|
||||
assert(593441861.isPseudoprime);
|
||||
assert(899809363.isPseudoprime);
|
||||
assert(982451653.isPseudoprime);
|
||||
}
|
||||
|
@ -1,53 +0,0 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
module tanya.meta.tests.transform;
|
||||
|
||||
import tanya.meta.transform;
|
||||
|
||||
@nogc nothrow pure @safe unittest
|
||||
{
|
||||
static assert(is(CommonType!(void*, int*) == void*));
|
||||
static assert(is(CommonType!(void*, const(int)*) == const(void)*));
|
||||
static assert(is(CommonType!(void*, const(void)*) == const(void)*));
|
||||
static assert(is(CommonType!(int*, void*) == void*));
|
||||
static assert(is(CommonType!(const(int)*, void*) == const(void)*));
|
||||
static assert(is(CommonType!(const(void)*, void*) == const(void)*));
|
||||
|
||||
static assert(is(CommonType!() == void));
|
||||
static assert(is(CommonType!(int*, const(int)*) == const(int)*));
|
||||
static assert(is(CommonType!(int**, const(int)**) == const(int*)*));
|
||||
|
||||
static assert(is(CommonType!(float, double) == double));
|
||||
static assert(is(CommonType!(float, int) == void));
|
||||
|
||||
static assert(is(CommonType!(bool, const bool) == bool));
|
||||
static assert(is(CommonType!(int, bool) == void));
|
||||
static assert(is(CommonType!(int, void) == void));
|
||||
static assert(is(CommonType!(Object, void*) == void));
|
||||
|
||||
class A
|
||||
{
|
||||
}
|
||||
static assert(is(CommonType!(A, Object) == Object));
|
||||
static assert(is(CommonType!(const(A)*, Object*) == const(Object)*));
|
||||
static assert(is(CommonType!(A, typeof(null)) == A));
|
||||
|
||||
class B : A
|
||||
{
|
||||
}
|
||||
class C : A
|
||||
{
|
||||
}
|
||||
static assert(is(CommonType!(B, C) == A));
|
||||
|
||||
static struct S
|
||||
{
|
||||
int opCast(T : int)()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
static assert(is(CommonType!(S, int) == void));
|
||||
static assert(is(CommonType!(const S, S) == const S));
|
||||
}
|
Loading…
Reference in New Issue
Block a user