From e566c5fa7f4b8af527c9f13f6eabd84bfc38a897 Mon Sep 17 00:00:00 2001
From: William S Fulton
SWIG correctly parses the = delete and = default -keywords. For example:
+SWIG handles explicitly defaulted functions, that is, = default added to a function declaration. Deleted definitions, which are also called deleted functions, have = delete added to the function declaration. +For example:
struct NonCopyable { NonCopyable& operator=(const NonCopyable&) = delete; /* Removes operator= */ - NonCopyable(const NonCopyable&) = delete; /* Removed copy constructor */ - NonCopyable() = default; /* Explicitly allows the empty constructor */ - void *operator new(std::size_t) = delete; /* Removes new NonCopyable */ + NonCopyable(const NonCopyable&) = delete; /* Removed copy constructor */ + NonCopyable() = default; /* Explicitly allows the empty constructor */ + void *operator new(std::size_t) = delete; /* Removes new NonCopyable */ };
This feature is specific to C++ only. The defaulting/deleting is currently ignored, because SWIG -automatically produces wrappers for special constructors and operators specific to the target language.
++Wrappers for deleted functions will not be available in the target language. +Wrappers for defaulted functions will of course be available in the target language. +Explicitly defaulted functions have no direct effect for SWIG wrapping as the declaration is handled +much like any other method declaration parsed by SWIG. +
This chapter gives you a brief overview about the SWIG @@ -68,10 +68,10 @@ Google Summer of Code 2009 period.
new STL types (unordered_ containers, result_of, tuples) are not supported yet. -SWIG correctly parses the new operator && the same as the reference operator &.
@@ -87,7 +87,7 @@ class MyClass { }; -SWIG correctly parses the keyword constexpr, but ignores its functionality. Constant functions cannot be used as constants.
@@ -105,7 +105,7 @@ constexpr int myConstFunc() { return MY_CONST; } const int a = MY_CONST; // ok -SWIG correctly parses the keywords extern template. However, the explicit template instantiation is not used by SWIG, a %template is still required.
@@ -123,7 +123,8 @@ public: }; -Initializer lists are very much a C++ compiler construct and are not very accessible from wrappers as @@ -254,7 +255,7 @@ Note that the default typemap for std::initializer_list does nothing bu and hence any user supplied typemaps will override it and suppress the warning.
-The curly brackets {} for member initialization are fully @@ -287,7 +288,7 @@ AltStruct var2{2, 4.3}; // calls the constructor 142.15 -
SWIG supports decltype() with some limitations. Single @@ -304,13 +305,13 @@ int i; int j; decltype(i+j) k; // syntax error -
This feature is part of the implementation block only. SWIG ignores it.
-SWIG correctly parses most of the Lambda functions syntax. For example:
@@ -336,7 +337,7 @@ auto six = [](int x, int y) { return x+y; }(4, 2); Better support should be available in a later release. -SWIG fully supports the new definition of functions. For example:
@@ -371,7 +372,7 @@ auto SomeStruct::FuncName(int x, int y) -> int { auto square(float a, float b) -> decltype(a); -@@ -412,12 +413,12 @@ class DerivedClass: public BaseClass { }; -
The nullptr constant is largely unimportant in wrappers. In the few places it has an effect, it is treated like NULL.
-SWIG parses the new enum class syntax and forward declarator for the enums:
@@ -468,7 +469,7 @@ class AllColors { }; -SWIG correctly parses the symbols >> as closing the @@ -479,7 +480,7 @@ shift operator >> otherwise.
std::vector<std::vector<int>> myIntTable; -SWIG correctly parses the keyword explicit both for operators and constructors. @@ -515,7 +516,8 @@ SWIG target languages, because all use their own facilities (eg. classes Cloneab to achieve particular copy and compare behaviours.
-The following is an example of an alias template: @@ -567,7 +569,7 @@ example.i:17: Warning 341: The 'using' keyword in type aliasing is not fully sup typedef void (*PFD)(double); // The old style -
SWIG fully supports any type inside a union even if it does not @@ -593,7 +595,7 @@ union P { } p1; -
SWIG supports the variadic templates syntax (inside the <> @@ -628,7 +630,7 @@ const int SIZE = sizeof...(ClassName<int, int>); In the above example SIZE is of course wrapped as a constant.
-SWIG supports unicode string constants and raw string literals.
@@ -652,7 +654,7 @@ const char32_t *ii = UR"XXX(I'm a "raw UTF-32" \ string.)XXX";Note: SWIG currently incorrectly parses the odd number of double quotes inside the string due to SWIG's C++ preprocessor.
-@@ -719,7 +721,7 @@ OutputType var2 = 1234_suffix; OutputType var3 = 3.1416_suffix; -
SWIG correctly parses the thread_local keyword. For example, variable @@ -761,12 +763,12 @@ Explicitly defaulted functions have no direct effect for SWIG wrapping as the de much like any other method declaration parsed by SWIG.
-SWIG correctly parses and uses the new long long type already introduced in C99 some time ago.
-SWIG correctly parses and calls the new static_assert function.
@@ -778,7 +780,7 @@ struct Check { }; -SWIG correctly calls the sizeof() on types as well as on the @@ -798,28 +800,28 @@ const int SIZE = sizeof(A::member); // does not work with C++03. Okay with C++11 8 -
SWIG does not currently wrap or use any of the new threading classes introduced (thread, mutex, locks, condition variables, task). The main reason is that SWIG target languages offer their own threading facilities that do not rely on C++.
-SWIG does not wrap the new tuple types and the unordered_ container classes yet. Variadic template support is working so it is possible to include the tuple header file; it is parsed without any problems.
-SWIG does not wrap the new C++11 regular expressions classes, because the SWIG target languages use their own facilities for this.
-@@ -827,12 +829,12 @@ SWIG provides special smart pointer handling for std::tr1::shared_ptr i There is no special smart pointer handling available for std::weak_ptr and std::unique_ptr.
-This feature extends and standardizes the standard library only and does not effect the C++ language and SWIG.
-The new ref and cref classes are used to instantiate a parameter as a reference of a template function. For example:
@@ -857,7 +859,7 @@ int main() {The ref and cref classes are not wrapped by SWIG because the SWIG target languages do not support referencing.
-@@ -888,7 +890,7 @@ t = Test() b = t(1,2) # invoke C++ function object -
The new C++ metaprogramming is useful at compile time and is aimed specifically for C++ development:
@@ -913,7 +915,7 @@ template< class T1, class T2 > int elaborate( T1 A, T2 B ) {SWIG correctly parses the template specialization, template types and values inside the <> block and the new helper functions: is_convertible, is_integral, is_const etc. However, SWIG still explicitly requires concrete types when using the %template directive, so the C++ metaprogramming features are not really of interest at runtime in the target languages.
-SWIG does not wrap the new result_of class introduced in the <functional> header and map the result_of::type to the concrete type yet. For example:
-- cgit v1.2.3 From cdefaaf794398655de5e93c4aa9f20fdb01e2283 Mon Sep 17 00:00:00 2001 From: William S Fulton+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: +
+ ++static void noex1() noexcept; +int noex2(int) noexcept(true); +int noex3(int, bool) noexcept(false); +
t = Test() b = t(1,2) # invoke C++ function object
Instead, please use decltype() where possible for now.
+