conv.emplace: Fix emplacing structs w/o this()
This commit is contained in:
parent
4f9927a8c3
commit
6d01680685
@ -1587,7 +1587,7 @@ struct Array(T)
|
||||
|
||||
@nogc nothrow pure @safe unittest
|
||||
{
|
||||
struct SWithDtor
|
||||
static struct SWithDtor
|
||||
{
|
||||
~this() @nogc nothrow pure @safe
|
||||
{
|
||||
|
@ -190,13 +190,17 @@ do
|
||||
static assert(is(typeof({ static T t; })),
|
||||
"Default constructor is disabled");
|
||||
}
|
||||
else static if (is(typeof(result.__ctor(args))))
|
||||
{
|
||||
result.__ctor(args);
|
||||
}
|
||||
else static if (is(typeof(T(args))))
|
||||
{
|
||||
*result = T(args);
|
||||
}
|
||||
else static if (is(typeof(result.__ctor(args))))
|
||||
else static if (is(typeof(*result = args))) // Args.length == 1, assignment
|
||||
{
|
||||
result.__ctor(args);
|
||||
*result = args;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -245,6 +249,19 @@ do
|
||||
static assert(is(typeof(emplace!F((void[]).init))));
|
||||
}
|
||||
|
||||
// Can emplace structs without a constructor
|
||||
@nogc nothrow pure @safe unittest
|
||||
{
|
||||
static struct SWithDtor
|
||||
{
|
||||
~this() @nogc nothrow pure @safe
|
||||
{
|
||||
}
|
||||
}
|
||||
static assert(is(typeof(emplace!SWithDtor(null, SWithDtor()))));
|
||||
static assert(is(typeof(emplace!SWithDtor(null))));
|
||||
}
|
||||
|
||||
/**
|
||||
* Thrown if a type conversion fails.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user