This repository was archived by the owner on Oct 12, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 410
Expand file tree
/
Copy pathexception.d
More file actions
106 lines (88 loc) · 2.6 KB
/
exception.d
File metadata and controls
106 lines (88 loc) · 2.6 KB
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
// Written in the D programming language.
/**
* Interface to C++ <exception>
*
* Copyright: Copyright (c) 2016 D Language Foundation
* License: $(HTTP boost.org/LICENSE_1_0.txt, Boost License 1.0).
* Authors: $(HTTP digitalmars.com, Walter Bright)
* Source: $(DRUNTIMESRC core/stdcpp/_exception.d)
*/
module core.stdcpp.exception;
alias exception = std.exception;
alias bad_exception = std.bad_exception;
alias bad_alloc = std.bad_alloc;
extern (C++, std):
version (CRuntime_DigitalMars)
{
import core.stdcpp.typeinfo;
alias void function() unexpected_handler;
unexpected_handler set_unexpected(unexpected_handler f) nothrow;
void unexpected();
alias void function() terminate_handler;
terminate_handler set_terminate(terminate_handler f) nothrow;
void terminate();
bool uncaught_exception();
class exception
{
this() nothrow { }
this(const exception) nothrow { }
//exception operator=(const exception) nothrow { return this; }
//virtual ~this() nothrow;
void dtor() { }
const(char)* what() const nothrow;
}
class bad_exception : exception
{
this() nothrow { }
this(const bad_exception) nothrow { }
//bad_exception operator=(const bad_exception) nothrow { return this; }
//virtual ~this() nothrow;
override const(char)* what() const nothrow;
}
}
else version (CRuntime_Glibc)
{
alias void function() unexpected_handler;
unexpected_handler set_unexpected(unexpected_handler f) nothrow;
void unexpected();
alias void function() terminate_handler;
terminate_handler set_terminate(terminate_handler f) nothrow;
void terminate();
pure bool uncaught_exception();
class exception
{
this();
//virtual ~this();
void dtor1();
void dtor2();
const(char)* what() const;
}
class bad_exception : exception
{
this();
//virtual ~this();
override const(char)* what() const;
}
}
else version (CRuntime_Microsoft)
{
class exception
{
this(const(char)* _Message = "unknown", int x = 1) { _Ptr = _Message; }
this(ref const(exception) _Right) { _Ptr = _Right._Ptr; }
~this() {}
const(char)* what() const { return _Ptr ? _Ptr : "unknown exception"; }
private:
const(char)* _Ptr;
}
class bad_exception : exception
{
this(const(char)* _Message = "bad exception") { super(_Message); }
~this() {}
}
class bad_alloc : exception
{
this() { super("bad allocation", 1); }
~this() {}
}
}