File tree Expand file tree Collapse file tree 1 file changed +12
-16
lines changed Expand file tree Collapse file tree 1 file changed +12
-16
lines changed Original file line number Diff line number Diff line change 173
173
C::C(int ii, double id)
174
174
try : i(f(ii)), d(id) {
175
175
// constructor statements
176
+ } catch (...) {
177
+ // handles exceptions thrown from the ctor-initializer and from the constructor statements
176
178
}
177
- catch (...) {
178
- // handles exceptions thrown from the ctor-initializer
179
- // and from the constructor statements
180
- }
181
-
182
179
\end {codeblock }
183
180
\end {example }
184
181
216
213
\begin {codeblock }
217
214
try {
218
215
// ...
219
- }
220
- catch(const char* p) {
216
+ } catch(const char* p) {
221
217
// handle character string exceptions here
222
218
}
223
219
\end {codeblock }
233
229
}
234
230
\end {codeblock }
235
231
can be caught by a handler for exceptions of type
236
- \tcode {Overflow}
232
+ \tcode {Overflow}:
237
233
\begin {codeblock }
238
234
try {
239
235
f(1.2);
389
385
A a;
390
386
Y y;
391
387
A b;
392
- return {}; // \# 1
388
+ return {}; // \# 1
393
389
} catch (...) {
394
390
}
395
- return {}; // \# 2
391
+ return {}; // \# 2
396
392
}
397
393
\end {codeblock }
398
394
At \# 1, the returned object of type \tcode {A} is constructed.
540
536
try {
541
537
g();
542
538
} catch (Overflow oo) {
543
- // ...
539
+ // ...
544
540
} catch (Matherr mm) {
545
- // ...
541
+ // ...
546
542
}
547
543
}
548
544
\end {codeblock }
799
795
\end {note }
800
796
\begin {example }
801
797
\begin {codeblock }
802
- extern void f(); // potentially-throwing
798
+ extern void f(); // potentially-throwing
803
799
804
800
void g() noexcept {
805
- f(); // valid, even if \tcode {f} throws
806
- throw 42; // valid, effectively a call to \tcode {std::terminate}
801
+ f(); // valid, even if \tcode {f} throws
802
+ throw 42; // valid, effectively a call to \tcode {std::terminate}
807
803
}
808
804
\end {codeblock }
809
805
The call to
914
910
};
915
911
struct B {
916
912
B() throw();
917
- B(const B&) = default; // implicit exception specification is \tcode {noexcept(true)}
913
+ B(const B&) = default; // implicit exception specification is \tcode {noexcept(true)}
918
914
B(B&&, int = (throw Y(), 0)) noexcept;
919
915
~B() noexcept(false);
920
916
};
You can’t perform that action at this time.
0 commit comments