This repository has been archived by the owner on Oct 12, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #760 from MartinNowak/dup
implement dup and idup library functions
- Loading branch information
Showing
11 changed files
with
438 additions
and
163 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/** | ||
* Contains traits for runtime internal usage. | ||
* | ||
* Copyright: Copyright Digital Mars 2014 -. | ||
* License: <a href="http://www.boost.org/LICENSE_1_0.txt">Boost License 1.0</a>. | ||
* Authors: Martin Nowak | ||
* Source: $(DRUNTIMESRC core/internal/_traits.d) | ||
*/ | ||
module core.internal.traits; | ||
|
||
/// taken from std.typetuple.TypeTuple | ||
template TypeTuple(TList...) | ||
{ | ||
alias TypeTuple = TList; | ||
} | ||
|
||
T trustedCast(T, U)(auto ref U u) @trusted pure nothrow | ||
{ | ||
return cast(T)u; | ||
} | ||
|
||
template Unconst(T) | ||
{ | ||
static if (is(T U == immutable U)) alias Unconst = U; | ||
else static if (is(T U == inout const U)) alias Unconst = U; | ||
else static if (is(T U == inout U)) alias Unconst = U; | ||
else static if (is(T U == const U)) alias Unconst = U; | ||
else alias Unconst = T; | ||
} | ||
|
||
/// taken from std.traits.Unqual | ||
template Unqual(T) | ||
{ | ||
version (none) // Error: recursive alias declaration @@@BUG1308@@@ | ||
{ | ||
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 | ||
{ | ||
static if (is(T U == immutable U)) alias Unqual = U; | ||
else static if (is(T U == shared inout const U)) alias Unqual = U; | ||
else static if (is(T U == shared inout U)) alias Unqual = U; | ||
else static if (is(T U == shared const U)) alias Unqual = U; | ||
else static if (is(T U == shared U)) alias Unqual = U; | ||
else static if (is(T U == inout const U)) alias Unqual = U; | ||
else static if (is(T U == inout U)) alias Unqual = U; | ||
else static if (is(T U == const U)) alias Unqual = U; | ||
else alias Unqual = T; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.