Skip to content

Commit 6bd18a4

Browse files
committed
Get rid of dynamic exception specification
1 parent 9c57143 commit 6bd18a4

File tree

4 files changed

+69
-73
lines changed

4 files changed

+69
-73
lines changed

examples/game.C

+1-2
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ struct game_exception : public std::exception {
4141
const char* what() {
4242
return message.c_str();
4343
}
44-
~game_exception() throw() {
45-
}
44+
~game_exception() = default;
4645
};
4746

4847
class game {

perl++/headers/helpers.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ namespace perl {
5050
const char* what() {
5151
return message.c_str();
5252
}
53-
~Runtime_exception() throw() {
54-
}
53+
~Runtime_exception() = default;
5554
};
5655

5756
class Out_of_bounds_exception : public Runtime_exception {

tap++/headers/tap++.h

+37-39
Original file line numberDiff line numberDiff line change
@@ -18,74 +18,72 @@ namespace TAP {
1818
//Return the variant of "Failed test" or "Failed
1919
//(TODO) test" required by whether the current test is
2020
//a todo test
21-
char const * failed_test_msg() throw();
21+
char const * failed_test_msg() noexcept;
2222
}
2323
class fatal_exception : public std::exception {
2424
std::string message;
2525
public:
2626
fatal_exception(const std::string& _message) : message(_message) {
2727
}
28-
const char* what() const throw() {
28+
const char* what() const noexcept {
2929
return message.c_str();
3030
}
31-
~fatal_exception() throw() {
32-
}
3331
};
3432
extern const details::skip_all_type skip_all;
3533
extern const details::no_plan_type no_plan;
36-
void plan(unsigned) throw(fatal_exception);
37-
void plan(const details::skip_all_type&, const std::string& = "") throw(fatal_exception);
38-
void plan(const details::no_plan_type&) throw();
39-
void done_testing() throw(fatal_exception);
40-
void done_testing(unsigned) throw(fatal_exception);
34+
void plan(unsigned);
35+
void plan(const details::skip_all_type&, const std::string& = "");
36+
void plan(const details::no_plan_type&);
37+
void done_testing();
38+
void done_testing(unsigned);
4139

42-
unsigned planned() throw();
43-
unsigned encountered() throw();
40+
unsigned planned();
41+
unsigned encountered();
4442

45-
bool ok(bool, const std::string& = "") throw();
46-
bool not_ok(bool, const std::string& = "") throw();
43+
bool ok(bool, const std::string& = "");
44+
bool not_ok(bool, const std::string& = "");
4745

48-
bool pass(const std::string& = "") throw();
49-
bool fail(const std::string& = "") throw();
46+
bool pass(const std::string& = "");
47+
bool fail(const std::string& = "");
5048

51-
void skip(unsigned, const std::string& = "") throw();
52-
void bail_out(const std::string& reason) throw();
49+
void skip(unsigned, const std::string& = "");
50+
void bail_out(const std::string& reason);
5351

54-
int exit_status() throw();
55-
bool summary() throw();
52+
int exit_status();
53+
bool summary();
5654

57-
void set_output(std::ostream&) throw(fatal_exception);
58-
void set_error(std::ostream&) throw(fatal_exception);
55+
void set_output(std::ostream&);
56+
void set_error(std::ostream&);
5957

60-
template<typename T> void diag(const T& first) throw() {
58+
template<typename T> void diag(const T& first) {
6159
*details::error << "# " << first << std::endl;
6260
}
63-
template<typename T1, typename T2> void diag(const T1& first, const T2& second) throw() {
61+
template<typename T1, typename T2> void diag(const T1& first, const T2& second) {
6462
*details::error << "# " << first << second << std::endl;
6563
}
66-
template<typename T1, typename T2, typename T3> void diag(const T1& first, const T2& second, const T3& third) throw() {
64+
template<typename T1, typename T2, typename T3> void diag(const T1& first, const T2& second, const T3& third) {
6765
*details::error << "# " << first << second << third << std::endl;
6866
}
69-
template<typename T1, typename T2, typename T3, typename T4> void diag(const T1& first, const T2& second, const T3& third, const T4& fourth) throw() {
67+
template<typename T1, typename T2, typename T3, typename T4> void diag(const T1& first, const T2& second, const T3& third, const T4& fourth) {
7068
*details::error << "# " << first << second << third << fourth << std::endl;
7169
}
72-
template<typename T1, typename T2, typename T3, typename T4, typename T5> void diag(const T1& first, const T2& second, const T3& third, const T4& fourth, const T5& fifth) throw() {
70+
template<typename T1, typename T2, typename T3, typename T4, typename T5> void diag(const T1& first, const T2& second, const T3& third, const T4& fourth, const T5& fifth) {
7371
*details::error << "# " << first << second << third << fourth << fifth << std::endl;
7472
}
7573

76-
template<typename T> void note(const T& first) throw() {
74+
template<typename T> void note(const T& first) {
7775
*details::output << "# " << first << std::endl;
7876
}
79-
template<typename T1, typename T2> void note(const T1& first, const T2& second) throw() {
77+
template<typename T1, typename T2> void note(const T1& first, const T2& second) {
8078
*details::output << "# " << first << second << std::endl;
8179
}
82-
template<typename T1, typename T2, typename T3> void note(const T1& first, const T2& second, const T3& third) throw() {
80+
template<typename T1, typename T2, typename T3> void note(const T1& first, const T2& second, const T3& third) {
8381
*details::output << "# " << first << second << third << std::endl;
8482
}
85-
template<typename T1, typename T2, typename T3, typename T4> void note(const T1& first, const T2& second, const T3& third, const T4& fourth) throw() {
83+
template<typename T1, typename T2, typename T3, typename T4> void note(const T1& first, const T2& second, const T3& third, const T4& fourth) {
8684
*details::output << "# " << first << second << third << fourth << std::endl;
8785
}
88-
template<typename T1, typename T2, typename T3, typename T4, typename T5> void note(const T1& first, const T2& second, const T3& third, const T4& fourth, const T5& fifth) throw() {
86+
template<typename T1, typename T2, typename T3, typename T4, typename T5> void note(const T1& first, const T2& second, const T3& third, const T4& fourth, const T5& fifth) {
8987
*details::output << "# " << first << second << third << fourth << fifth << std::endl;
9088
}
9189

@@ -172,8 +170,8 @@ namespace TAP {
172170
class todo_guard {
173171
const std::string value;
174172
public:
175-
todo_guard() throw();
176-
~todo_guard() throw();
173+
todo_guard();
174+
~todo_guard();
177175
};
178176
}
179177

@@ -183,22 +181,22 @@ namespace TAP {
183181
namespace details {
184182
struct Skip_exception {
185183
const std::string reason;
186-
Skip_exception(const std::string& _reason) throw() : reason(_reason) {
184+
Skip_exception(const std::string& _reason) : reason(_reason) {
187185
}
188186
};
189187
struct Todo_exception {
190188
const std::string reason;
191-
Todo_exception(const std::string& _reason) throw() : reason(_reason) {
189+
Todo_exception(const std::string& _reason) : reason(_reason) {
192190
}
193191
};
194192

195-
void start_block(unsigned) throw();
196-
unsigned stop_block() throw(fatal_exception);
193+
void start_block(unsigned);
194+
unsigned stop_block();
197195

198196
}
199197

200-
void skip(const std::string& reason) throw(details::Skip_exception);
201-
void skip_todo(const std::string& reason) throw(details::Todo_exception);
198+
void skip(const std::string& reason);
199+
void skip_todo(const std::string& reason);
202200
}
203201

204202
#define TRY(action, name) do {\

tap++/source/tap++.C

+30-30
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace TAP {
1515
unsigned counter = 0;
1616
unsigned not_oks = 0;
1717

18-
std::string todo_test() throw() {
18+
std::string todo_test() {
1919
if (TODO == "") {
2020
return TODO;
2121
}
@@ -24,24 +24,24 @@ namespace TAP {
2424
}
2525
}
2626

27-
bool is_todo_test() throw() { return TODO != ""; }
27+
bool is_todo_test() noexcept { return TODO != ""; }
2828

2929
bool is_planned = false;
3030
bool no_planned = false;
3131
bool has_output_plan = false;
3232

33-
void output_plan(unsigned tests, const std::string& extra = "") throw(fatal_exception) {
33+
void output_plan(unsigned tests, const std::string& extra = "") {
3434
if (has_output_plan) {
3535
throw fatal_exception("Can't plan twice");
3636
}
3737
*details::output << "1.." << tests << extra << std::endl;
3838
has_output_plan = true;
3939
}
40-
inline const std::string to_string(unsigned num) throw() {
40+
inline const std::string to_string(unsigned num) {
4141
return boost::lexical_cast<std::string>(num);
4242
}
4343

44-
inline void _done_testing(unsigned tests) throw(fatal_exception) {
44+
inline void _done_testing(unsigned tests) {
4545
static bool is_done = false;
4646
if (is_done) {
4747
fail("done_testing() was already called");
@@ -63,40 +63,40 @@ namespace TAP {
6363

6464
}
6565

66-
void plan(unsigned tests) throw(fatal_exception) {
66+
void plan(unsigned tests) {
6767
if (is_planned) {
6868
bail_out("Can't plan again!");
6969
}
7070
is_planned = true;
7171
output_plan(tests);
7272
expected = tests;
7373
}
74-
void plan(const details::skip_all_type&, const std::string& reason) throw(fatal_exception) {
74+
void plan(const details::skip_all_type&, const std::string& reason) {
7575
output_plan(0, " #skip " + reason);
7676
std::exit(0);
7777
}
78-
void plan(const details::no_plan_type&) throw() {
78+
void plan(const details::no_plan_type&) {
7979
is_planned = true;
8080
no_planned = true;
8181
}
8282

83-
void done_testing() throw(fatal_exception) {
83+
void done_testing() {
8484
_done_testing(encountered());
8585
}
8686

87-
void done_testing(unsigned tests) throw(fatal_exception) {
87+
void done_testing(unsigned tests) {
8888
no_planned = false;
8989
_done_testing(tests);
9090
}
9191

92-
unsigned planned() throw() {
92+
unsigned planned() {
9393
return expected;
9494
}
95-
unsigned encountered() throw() {
95+
unsigned encountered() {
9696
return counter;
9797
}
9898

99-
int exit_status() throw () {
99+
int exit_status() {
100100
// bool passing;
101101
if (!is_planned && encountered()) {
102102
diag("Tests were run but no plan was declared and done_testing() was not seen.");
@@ -112,80 +112,80 @@ namespace TAP {
112112
return 255;
113113
}
114114
}
115-
bool summary() throw() {
115+
bool summary() {
116116
return not_oks;
117117
}
118118

119-
void bail_out(const std::string& reason) throw() {
119+
void bail_out(const std::string& reason) {
120120
*details::output << "Bail out! " << reason << std::endl;
121121
std::exit(255); // Does not unwind stack!
122122
}
123123

124-
bool ok(bool is_ok, const std::string& message) throw() {
124+
bool ok(bool is_ok, const std::string& message) {
125125
const char* hot_or_not = is_ok ? "" : "not ";
126126
*details::output << hot_or_not << "ok " << ++counter<< " - " << message << todo_test() << std::endl;
127127
if (!is_ok && !is_todo_test()) {
128128
++not_oks;
129129
}
130130
return is_ok;
131131
}
132-
bool not_ok(bool is_not_ok, const std::string& message) throw() {
132+
bool not_ok(bool is_not_ok, const std::string& message) {
133133
return !ok(!is_not_ok, message);
134134
}
135135

136-
bool pass(const std::string& message) throw() {
136+
bool pass(const std::string& message) {
137137
return ok(true, message);
138138
}
139-
bool fail(const std::string& message) throw() {
139+
bool fail(const std::string& message) {
140140
return ok(false, message);
141141
}
142142

143-
void skip(unsigned num, const std::string& reason) throw () {
143+
void skip(unsigned num, const std::string& reason) {
144144
for(unsigned i = 0; i < num; ++i) {
145145
pass(" # skip " + reason);
146146
}
147147
}
148148

149-
void set_output(std::ostream& new_output) throw (fatal_exception) {
149+
void set_output(std::ostream& new_output) {
150150
if (is_planned) {
151151
throw fatal_exception("Can't set output after plan()");
152152
}
153153
details::output = &new_output;
154154
}
155-
void set_error(std::ostream& new_error) throw(fatal_exception) {
155+
void set_error(std::ostream& new_error) {
156156
if (is_planned) {
157157
throw fatal_exception("Can't set error after plan()");
158158
}
159159
details::error = &new_error;
160160
}
161-
todo_guard::todo_guard() throw() : value(TODO) {
161+
todo_guard::todo_guard() : value(TODO) {
162162
}
163-
todo_guard::~todo_guard() throw() {
163+
todo_guard::~todo_guard() {
164164
TODO = value;
165165
}
166166
namespace details {
167167
std::ostream* output = &std::cout;
168168
std::ostream* error = &std::cout;
169169
static std::stack<unsigned> block_expected;
170-
void start_block(unsigned expected) throw() {
170+
void start_block(unsigned expected) {
171171
block_expected.push(encountered() + expected);
172172
}
173-
unsigned stop_block() throw(fatal_exception) {
173+
unsigned stop_block() {
174174
unsigned ret = block_expected.top();
175175
block_expected.pop();
176176
return ret;
177177
}
178178

179-
char const * failed_test_msg() throw() {
180-
return is_todo_test()?"Failed (TODO) test":"Failed test";
179+
char const * failed_test_msg() noexcept {
180+
return is_todo_test() ? "Failed (TODO) test" : "Failed test";
181181
}
182182

183183
}
184184

185-
void skip(const std::string& reason) throw(details::Skip_exception) {
185+
void skip(const std::string& reason) {
186186
throw details::Skip_exception(reason);
187187
}
188-
void skip_todo(const std::string& reason) throw(details::Todo_exception) {
188+
void skip_todo(const std::string& reason) {
189189
throw details::Todo_exception(reason);
190190
}
191191

0 commit comments

Comments
 (0)