This repository has been archived by the owner on Oct 12, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 426
/
xutility.d
76 lines (65 loc) · 2.43 KB
/
xutility.d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/**
* D header file for interaction with Microsoft C++ <xutility>
*
* Copyright: Copyright (c) 2018 D Language Foundation
* License: Distributed under the
* $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
* (See accompanying file LICENSE)
* Authors: Manu Evans
* Source: $(DRUNTIMESRC core/stdcpp/xutility.d)
*/
module core.stdcpp.xutility;
enum CppStdRevision : uint
{
cpp98 = 199711,
cpp11 = 201103,
cpp14 = 201402,
cpp17 = 201703
}
enum __cplusplus = __traits(getTargetInfo, "cppStd");
// wrangle C++ features
enum __cpp_sized_deallocation = __cplusplus >= CppStdRevision.cpp14 ? 201309 : 0;
enum __cpp_aligned_new = __cplusplus >= CppStdRevision.cpp17 ? 201606 : 0;
extern(C++, "std"):
version (CppRuntime_Microsoft)
{
// Client code can mixin the set of MSVC linker directives
mixin template MSVCLinkDirectives(bool failMismatch = false)
{
import core.stdcpp.xutility : __CXXLIB__;
static if (__CXXLIB__ == "libcmtd")
{
pragma(lib, "libcpmtd");
static if (failMismatch)
pragma(linkerDirective, "/FAILIFMISMATCH:RuntimeLibrary=MTd_StaticDebug");
}
else static if (__CXXLIB__ == "msvcrtd")
{
pragma(lib, "msvcprtd");
static if (failMismatch)
pragma(linkerDirective, "/FAILIFMISMATCH:RuntimeLibrary=MDd_DynamicDebug");
}
else static if (__CXXLIB__ == "libcmt")
{
pragma(lib, "libcpmt");
static if (failMismatch)
pragma(linkerDirective, "/FAILIFMISMATCH:RuntimeLibrary=MT_StaticRelease");
}
else static if (__CXXLIB__ == "msvcrt")
{
pragma(lib, "msvcprt");
static if (failMismatch)
pragma(linkerDirective, "/FAILIFMISMATCH:RuntimeLibrary=MD_DynamicRelease");
}
}
// convenient alias for the C++ std library name
enum __CXXLIB__ = __traits(getTargetInfo, "cppRuntimeLibrary");
package:
// these are all [[noreturn]]
void _Xbad() nothrow @trusted @nogc;
void _Xinvalid_argument(const(char)* message) nothrow @trusted @nogc;
void _Xlength_error(const(char)* message) nothrow @trusted @nogc;
void _Xout_of_range(const(char)* message) nothrow @trusted @nogc;
void _Xoverflow_error(const(char)* message) nothrow @trusted @nogc;
void _Xruntime_error(const(char)* message) nothrow @trusted @nogc;
}