ADTast-experimentalenumforall-pointer-decayjacob/cs343-translationnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change
on this file since 943bfad was
ea593a3,
checked in by Andrew Beach <ajbeach@…>, 3 years ago
|
First draft of all the exception benchmarks. There is an issue with the Cforall linking.
|
-
Property mode set to
100644
|
File size:
696 bytes
|
Line | |
---|
1 | // Throw Across Destructor |
---|
2 | #include <exception> |
---|
3 | #include <cstdlib> |
---|
4 | |
---|
5 | struct EmptyException : public std::exception {}; |
---|
6 | |
---|
7 | struct WithDestructor { |
---|
8 | ~WithDestructor() {} |
---|
9 | }; |
---|
10 | |
---|
11 | void unwind_destructor(unsigned int frames) { |
---|
12 | if (frames) { |
---|
13 | WithDestructor object; |
---|
14 | unwind_destructor(frames - 1); |
---|
15 | } else { |
---|
16 | throw (EmptyException){}; |
---|
17 | } |
---|
18 | } |
---|
19 | |
---|
20 | int main(int argc, char * argv[]) { |
---|
21 | unsigned int times = 1; |
---|
22 | unsigned int total_frames = 1; |
---|
23 | if (2 < argc) { |
---|
24 | times = strtol(argv[1], nullptr, 10); |
---|
25 | } |
---|
26 | if (3 < argc) { |
---|
27 | total_frames = strtol(argv[2], nullptr, 10); |
---|
28 | } |
---|
29 | |
---|
30 | for (int count = 0 ; count < times ; ++count) { |
---|
31 | try { |
---|
32 | unwind_destructor(total_frames); |
---|
33 | } catch (EmptyException &) { |
---|
34 | // ... |
---|
35 | } |
---|
36 | } |
---|
37 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.