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

Moved move, moveEmplace, and forward to core.lifetime #2442

Merged
merged 1 commit into from
Jan 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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`, `std.algorithm.mutation.moveEmplace`, 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`, `moveEmplace`, 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