Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Commit

Permalink
Moved move and forward to core.lifetime.
Browse files Browse the repository at this point in the history
  • Loading branch information
TurkeyMan committed Jan 5, 2019
1 parent 227a925 commit 37eb380
Show file tree
Hide file tree
Showing 3 changed files with 676 additions and 3 deletions.
3 changes: 2 additions & 1 deletion changelog/emplace.dd
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Moved `std.conv.emplace` to core/lifetime.d
Moved `std.conv.emplace`, `std.algorithm.mutation.move`, and `std.functional.forward` to core/lifetime.d

`emplace` is the counterpart to `destroy`, so it has been moved to also live in druntime (core/lifetime.d) where it is accessible by projects that use a shallow runtime library stack.
`move` and `forward` are related low-level construction machinery which also belong in `core.lifetime`.
13 changes: 11 additions & 2 deletions src/core/internal/traits.d
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ template TypeTuple(TList...)
{
alias TypeTuple = TList;
}
alias AliasSeq = TypeTuple;

template FieldTypeTuple(T)
{
Expand Down Expand Up @@ -203,7 +204,7 @@ template anySatisfy(alias F, T...)
}

// simplified from std.traits.maxAlignment
private template maxAlignment(U...)
template maxAlignment(U...)
{
static if (U.length == 0)
static assert(0);
Expand All @@ -220,7 +221,7 @@ private template maxAlignment(U...)
}

// std.traits.Fields
private template Fields(T)
template Fields(T)
{
static if (is(T == struct) || is(T == union))
alias Fields = typeof(T.tupleof[0 .. $ - __traits(isNested, T)]);
Expand Down Expand Up @@ -325,3 +326,11 @@ template staticMap(alias F, T...)
staticMap!(F, T[$/2 .. $ ]));
}
}

// std.exception.assertCTFEable
version (unittest) package(core)
void assertCTFEable(alias dg)()
{
static assert({ cast(void) dg(); return true; }());
cast(void) dg();
}
Loading

0 comments on commit 37eb380

Please sign in to comment.