mirror of
https://review.haiku-os.org/buildtools
synced 2025-02-12 00:37:41 +01:00
Updated dependencies: * GMP 6.2.1 * ISL 0.24 * MPL 1.2.1 * MPFR 4.1.0 The dependencies were pulled in by running the ./contrib/download_prerequisites script and then manually removing the symbolic links and archives, and renaming the directories (i.e mv isl-0.24 to isl)
48 lines
1.2 KiB
D
48 lines
1.2 KiB
D
/**
|
|
This module contains implementations for destroying instances of types
|
|
|
|
Copyright: Copyright Digital Mars 2000 - 2019.
|
|
License: Distributed under the
|
|
$(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
|
|
(See accompanying file LICENSE)
|
|
Source: $(DRUNTIMESRC core/_internal/_destruction.d)
|
|
*/
|
|
module core.internal.destruction;
|
|
|
|
// compiler frontend lowers dynamic array deconstruction to this
|
|
void __ArrayDtor(T)(scope T[] a)
|
|
{
|
|
foreach_reverse (ref T e; a)
|
|
e.__xdtor();
|
|
}
|
|
|
|
public void destructRecurse(E, size_t n)(ref E[n] arr)
|
|
{
|
|
import core.internal.traits : hasElaborateDestructor;
|
|
|
|
static if (hasElaborateDestructor!E)
|
|
{
|
|
foreach_reverse (ref elem; arr)
|
|
destructRecurse(elem);
|
|
}
|
|
}
|
|
|
|
public void destructRecurse(S)(ref S s)
|
|
if (is(S == struct))
|
|
{
|
|
static if (__traits(hasMember, S, "__xdtor") &&
|
|
// Bugzilla 14746: Check that it's the exact member of S.
|
|
__traits(isSame, S, __traits(parent, s.__xdtor)))
|
|
s.__xdtor();
|
|
}
|
|
|
|
// Test static struct
|
|
nothrow @safe @nogc unittest
|
|
{
|
|
static int i = 0;
|
|
static struct S { ~this() nothrow @safe @nogc { i = 42; } }
|
|
S s;
|
|
destructRecurse(s);
|
|
assert(i == 42);
|
|
}
|