summaryrefslogtreecommitdiff
path: root/Examples/test-suite/cpp11_unrestricted_unions.i
blob: 5facaafe1c6b85683b0540edee87fab183415f90 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/* This testcase checks whether SWIG correctly parses the support for types
   without the defined trivial constructor in the unions. */
%module cpp11_unrestricted_unions

%inline %{
struct point {
  point() {}
  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++03; legal in C++11.
  // Due to the point member, a constructor definition is required.
  P() {
    new(&p) point();
  }
} p1;
%}