Fix unrestricted unions testcase and add runtime example

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2009-matevz@13849 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2012-09-21 19:15:44 +00:00
commit e25da884cb
4 changed files with 4061 additions and 5 deletions

View file

@ -439,19 +439,24 @@ typedef void (*PFD)(double); // The old style
<p>SWIG fully supports any type inside a union even if it does not
define a trivial constructor. For example, the wrapper for the following
code is correctly produced:</p>
code correctly provides access to all members in the union:</p>
<div class="code"><pre>
struct point {
point() {}
point(int x, int y): x_(x), y_(y) {}
point(int x, int y) : x_(x), y_(y) {}
int x_, y_;
};
#include <new> // For placement 'new' in the constructor below
union P {
int z;
double w;
point p; // Illegal in C++; point has a non-trivial constructor. However, this is legal in C++0x.
point p; // Illegal in C++03; legal in C++11.
// Due to the point member, a constructor definition is required.
P() {
new(&amp;p) point();
}
} p1;
</pre></div>