Permalink
Browse files

Add support for C++11 noexcept specification in exception specifications

  • Loading branch information...
1 parent cdefaaf commit f4ada30a7e6f0b15ed4a1446675980b6df15b631 @wsfulton wsfulton committed Nov 21, 2013
@@ -37,6 +37,7 @@
<li><a href="#CPlusPlus11_type_long_long_int">Type long long int</a>
<li><a href="#CPlusPlus11_static_assertions">Static assertions</a>
<li><a href="#CPlusPlus11_allow_sizeof_to_work_on_members_of_classes_without_an_explicit_object">Allow sizeof to work on members of classes without an explicit object</a>
+<li><a href="#CPlusPlus11_noexcept">Exception specifications and noexcept</a>
</ul>
<li><a href="#CPlusPlus11_standard_library_changes">Standard library changes</a>
<ul>
@@ -583,7 +584,7 @@
int x_, y_;
};
-#include <new> // For placement 'new' in the constructor below
+#include &lt;new&gt; // For placement 'new' in the constructor below
union P {
int z;
double w;
@@ -800,6 +801,23 @@
8
</pre></div>
+<H3><a name="CPlusPlus11_noexcept"></a>7.2.25 Exception specifications and noexcept</H3>
+
+
+<p>
+C++11 added in the noexcept specification to exception specifications to indicate that a function simply may or may not throw an exception, without actually naming any exception.
+SWIG understands these, although there isn't any useful way that this information can be taken advantage of by target languages,
+so it is as good as ignored during the wrapping process.
+Below are some examples of noexcept in function declarations:
+</p>
+
+<div class="code"><pre>
+static void noex1() noexcept;
+int noex2(int) noexcept(true);
+int noex3(int, bool) noexcept(false);
+</pre></div>
+
+
<H2><a name="CPlusPlus11_standard_library_changes"></a>7.3 Standard library changes</H2>
@@ -885,7 +903,7 @@
It does not involve <tt>std::function</tt>.
</p>
-<div class="targetlang">
+<div class="targetlang"><pre>
t = Test()
b = t(1,2) # invoke C++ function object
</pre></div>
@@ -944,5 +962,6 @@
</pre></div>
<p>Instead, please use <tt>decltype()</tt> where possible for now.</p>
+
</body>
</html>
@@ -491,6 +491,7 @@ CPP11_TEST_CASES = \
cpp11_initializer_list \
cpp11_initializer_list_extend \
cpp11_lambda_functions \
+ cpp11_noexcept \
cpp11_null_pointer_constant \
cpp11_raw_string_literals \
cpp11_rvalue_reference \
@@ -0,0 +1,48 @@
+%module cpp11_noexcept
+
+%ignore NoExceptClass(NoExceptClass&&);
+%rename(Assignment) NoExceptClass::operator=;
+
+%inline %{
+
+extern "C" void global_noexcept(int, bool) noexcept;
+
+struct NoExceptClass {
+ static const bool VeryTrue = true;
+
+ NoExceptClass() noexcept {}
+ NoExceptClass(const NoExceptClass&) noexcept {}
+ NoExceptClass(NoExceptClass&&) noexcept {}
+ NoExceptClass& operator=(const NoExceptClass&) noexcept {}
+ ~NoExceptClass() noexcept {}
+
+ void noex0() noexcept {}
+ void noex1() noexcept(sizeof(int) == 4) {}
+ void noex2() noexcept(true) {}
+ void noex3() noexcept(false) {}
+ void noex4() noexcept(VeryTrue) {}
+
+ template<typename T> void template_noexcept(T) noexcept {}
+
+ void noo1() const noexcept {}
+ static void noo2() noexcept {}
+ virtual void noo3() const noexcept {}
+ virtual void noo4() const noexcept = delete;
+ virtual void noo5() const throw() = delete;
+};
+
+struct NoExceptAbstract {
+ virtual void noo4() const noexcept = 0;
+ virtual ~NoExceptAbstract() noexcept = 0;
+};
+
+struct NoExceptDefaultDelete {
+// NoExceptDefaultDelete() noexcept = default;
+// NoExceptDefaultDelete(const NoExceptDefaultDelete&) noexcept = delete;
+ NoExceptDefaultDelete(NoExceptDefaultDelete&&) = delete;
+ NoExceptDefaultDelete& operator=(const NoExceptDefaultDelete&) = delete;
+ ~NoExceptDefaultDelete() noexcept = default;
+};
+
+%}
+
View
@@ -705,6 +705,8 @@ int yylex(void) {
}
if (strcmp(yytext, "throw") == 0)
return (THROW);
+ if (strcmp(yytext, "noexcept") == 0)
+ return (NOEXCEPT);
if (strcmp(yytext, "try") == 0)
return (yylex());
if (strcmp(yytext, "catch") == 0)
Oops, something went wrong.

0 comments on commit f4ada30

Please sign in to comment.