Debian Codegraph @

libphobos/libdruntime/rt/util/utility.d

raw
1 /**
2 * Contains various utility functions used by the runtime implementation.
3 *
4 * Copyright: Copyright Digital Mars 2016.
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 * Authors: Jacob Carlborg
9 * Source: $(DRUNTIMESRC rt/util/_utility.d)
10 */
11 module rt.util.utility;
12
13 /**
14 * Asserts that the given condition is `true`.
15 *
16 * The assertion is independent from -release, by abort()ing. Regular assertions
17 * throw an AssertError and thus require an initialized GC, which might not be
18 * the case (yet or anymore) for the startup/shutdown code in this package
19 * (called by CRT ctors/dtors etc.).
20 */
21 package(rt) void safeAssert(
22 bool condition, scope string msg, scope string file = __FILE__, size_t line = __LINE__
23 ) nothrow @nogc @safe
24 {
25 import core.internal.abort;
26 condition || abort(msg, file, line);
27 }
28
29 // @@@DEPRECATED_2.105@@@
30 // Remove this when complex types have been removed from the language.
31 package(rt)
32 {
33 private struct _Complex(T) { T re; T im; }
34
35 enum __c_complex_float : _Complex!float;
36 enum __c_complex_double : _Complex!double;
37 enum __c_complex_real : _Complex!real; // This is why we don't use stdc.config
38
39 alias d_cfloat = __c_complex_float;
40 alias d_cdouble = __c_complex_double;
41 alias d_creal = __c_complex_real;
42
43 enum isComplex(T) = is(T == d_cfloat) || is(T == d_cdouble) || is(T == d_creal);
44 }