1 /* This testcase checks whether SWIG syntactically correctly parses the initialization syntax using
2    {} braces for uniform member initialization. */
3 %module cpp11_uniform_initialization
4 
5 %include <std_vector.i>
6 
7 %template(VectorInt) std::vector<int>;
8 
9 %inline %{
10 struct BasicStruct {
11  int x;
12  double y;
13 };
14 
15 struct AltStruct {
AltStructAltStruct16   AltStruct(int x, double y) : x_{x}, y_{y} {}
getXAltStruct17   int getX() { return x_; }
getYAltStruct18   double getY() { return y_; }
19 
20 private:
21   int x_;
22   double y_;
23 };
24 
25 BasicStruct var1{5, 3.2}; // only fills the struct components
26 AltStruct var2{2, 4.3};   // calls the constructor
27 
28 class MoreInit
29 {
30 public:
31   int yarray[5] {1,2,3,4,5};
32   char *charptr {nullptr};
33   std::vector<int> vi {1,2,3,4,5};
34 
MoreInit()35   MoreInit() {}
36 
37   int more1(std::vector<int> vv = {1,2,3,4}) {
38     int sum = 0;
39     for (int i : vv)
40       sum += i;
41     return sum;
42   }
43 };
44 const int arr1[] = {1,2,3};
45 const int arr2[]{1,2,3};
46 const int arr3[][3]{ {1,2,3}, {4,5,6} };
47 const int arr4[][3] = { {1,2,3}, {4,5,6} };
48 %}
49 
50