diff --git a/Doc/Manual/CPlusPlus11.html b/Doc/Manual/CPlusPlus11.html index 9d315d8e3..86a042d78 100644 --- a/Doc/Manual/CPlusPlus11.html +++ b/Doc/Manual/CPlusPlus11.html @@ -62,12 +62,15 @@
This chapter gives you a brief overview about the SWIG implementation of the C++11 standard. This part of SWIG is still a work in -progress. Initial C++11 support for SWIG was written during the -Google Summer of Code 2009 period.
-SWIG supports all the new C++ syntax changes with some minor limitations +progress. +
+SWIG supports the new C++ syntax changes with some minor limitations (decltype expressions, variadic templates number). Wrappers for the -new STL types (unordered_ containers, result_of, tuples) are not supported -yet.
+new STL types (unordered_ containers, result_of, tuples) are incomplete. +The wrappers for the new containers would work much like the C++03 containers and +users are welcome to help by adapting the existing container interface files and submitting them +as a patch for inclusion in future versions of SWIG. +SWIG correctly parses the new operator && the same as the reference operator &.
++SWIG correctly parses the rvalue reference syntax '&&', +for example the typical usage of it in the move constructor and move assignment operator below: +
-The wrapper for the following code is correctly produced:
class MyClass {
- MyClass(MyClass&& p) : ptr(p.ptr) {p.ptr = 0;}
- MyClass& operator=(MyClass&& p) {
- std::swap(ptr, p.ptr);
+...
+ std::vector numbers;
+public:
+ MyClass(MyClass &&other) : numbers(std::move(other.numbers)) {}
+ MyClass & operator=(MyClass &&other) {
+ numbers = std::move(other.numbers);
return *this;
}
};
+Rvalue references are designed for C++ temporaries and so are not very useful when used from non-C++ target languages. +Generally you would just ignore them via %ignore before parsing the class. +For example, ignore the move constructor: +
+ ++%ignore MyClass::MyClass(MyClass &&); +
+The plan is to ignore them by default in a future version of SWIG. Note that both normal assignment operators as well as move assignment operators are ignored by default in most target languages with the following warning: +
+ ++example.i:18: Warning 503: Can't wrap 'operator =' unless renamed to a valid identifier. ++
template <typename... BaseClasses> class ClassName : public BaseClasses... {
public:
- ClassName (BaseClasses&&... baseClasses) : BaseClasses(baseClasses)... {}
+ ClassName (BaseClasses &&... baseClasses) : BaseClasses(baseClasses)... {}
}
struct NonCopyable {
- NonCopyable& operator=(const NonCopyable&) = delete; /* Removes operator= */
- NonCopyable(const NonCopyable&) = delete; /* Removed copy constructor */
+ 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 */
};
@@ -881,19 +910,19 @@ There is no special smart pointer handling available for std::weak_ptr
The new ref and cref classes are used to instantiate a parameter as a reference of a template function. For example:
-void f( int &r ) { r++; }
+void f(int &r) { r++; }
// Template function.
-template< class F, class P > void g( F f, P t ) { f(t); }
+template< class F, class P > void g(F f, P t) { f(t); }
int main() {
int i = 0 ;
- g( f, i ) ; // 'g<void ( int &r ), int>' is instantiated
- // then 'i' will not be modified.
+ g(f, i) ; // 'g<void (int &r), int>' is instantiated
+ // then 'i' will not be modified.
cout << i << endl ; // Output -> 0
- g( f, ref(i) ) ; // 'g<void(int &r),reference_wrapper<int>>' is instantiated
- // then 'i' will be modified.
+ g(f, ref(i)) ; // 'g<void(int &r),reference_wrapper<int>>' is instantiated
+ // then 'i' will be modified.
cout << i << endl ; // Output -> 1
}
@@ -939,17 +968,17 @@ b = t(1,2) # invoke C++ function object
// First way of operating.
template< bool B > struct algorithm {
- template< class T1, class T2 > int do_it( T1&, T2& ) { /*...*/ }
+ template< class T1, class T2 > int do_it(T1 &, T2 &) { /*...*/ }
};
// Second way of operating.
template<> struct algorithm<true> {
- template< class T1, class T2 > int do_it( T1, T2 ) { /*...*/ }
+ template< class T1, class T2 > int do_it(T1, T2) { /*...*/ }
};
// Instantiating 'elaborate' will automatically instantiate the correct way to operate.
-template< class T1, class T2 > int elaborate( T1 A, T2 B ) {
+template< class T1, class T2 > int elaborate(T1 A, T2 B) {
// Use the second way only if 'T1' is an integer and if 'T2' is
// in floating point, otherwise use the first way.
- return algorithm< is_integral<T1>::value && is_floating_point<T2>::value >::do_it( A, B );
+ return algorithm< is_integral<T1>::value && is_floating_point<T2>::value >::do_it(A, B);
}