2 This module contains implementations for destroying instances of types
4 Copyright: Copyright Digital Mars 2000 - 2019.
5 License: Distributed under the
6 $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
7 (See accompanying file LICENSE)
8 Source: $(DRUNTIMESRC core/_internal/_destruction.d)
10 module core
.internal
.destruction
;
12 // compiler frontend lowers dynamic array deconstruction to this
13 void __ArrayDtor(T
)(scope T
[] a
)
15 foreach_reverse (ref T e
; a
)
19 public void destructRecurse(E
, size_t n
)(ref E
[n
] arr
)
21 import core
.internal
.traits
: hasElaborateDestructor
;
23 static if (hasElaborateDestructor
!E
)
25 foreach_reverse (ref elem
; arr
)
26 destructRecurse(elem
);
30 public void destructRecurse(S
)(ref S s
)
33 static if (__traits(hasMember
, S
, "__xdtor") &&
34 // Bugzilla 14746: Check that it's the exact member of S.
35 __traits(isSame
, S
, __traits(parent
, s
.__xdtor
)))
40 nothrow @safe @nogc unittest
43 static struct S
{ ~this() nothrow @safe @nogc { i
= 42; } }