Examples update to support C++17: exception specification throw removal

This commit is contained in:
William S Fulton 2018-05-03 19:20:42 +01:00
commit c9a10eb726
10 changed files with 40 additions and 119 deletions

View file

@ -16,34 +16,26 @@ public:
char msg[256];
};
#if defined(_MSC_VER)
#pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
#endif
#if __GNUC__ >= 7
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated" // dynamic exception specifications are deprecated in C++11
#endif
class Test {
public:
int simple() throw(int) {
int simple() {
throw(37);
return 1;
}
int message() throw(const char *) {
int message() {
throw("I died.");
return 1;
}
int hosed() throw(Exc) {
int hosed() {
throw(Exc(42,"Hosed"));
return 1;
}
int unknown() throw(A*) {
int unknown() {
static A a;
throw &a;
return 1;
}
int multi(int x) throw(int, const char *, Exc) {
int multi(int x) {
if (x == 1) throw(37);
if (x == 2) throw("Bleah!");
if (x == 3) throw(Exc(42,"No-go-diggy-die"));
@ -51,10 +43,3 @@ public:
}
};
#if defined(_MSC_VER)
#pragma warning(default: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
#endif
#if __GNUC__ >= 7
#pragma GCC diagnostic pop
#endif

View file

@ -7,6 +7,12 @@
%include "std_string.i"
%catches(int) Test::simple();
%catches(const char *) Test::message();
%catches(Exc) Test::hosed();
%catches(A*) Test::unknown();
%catches(int, const char *, Exc) Test::multi(int x);
/* Let's just grab the original header file here */
%include "example.h"