File: cpp11_uniform_initialization.i

package info (click to toggle)
renderdoc 1.2%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 79,584 kB
  • sloc: cpp: 491,671; ansic: 285,823; python: 12,617; java: 11,345; cs: 7,181; makefile: 6,703; yacc: 5,682; ruby: 4,648; perl: 3,461; php: 2,119; sh: 2,068; lisp: 1,835; tcl: 1,068; ml: 747; xml: 137
file content (49 lines) | stat: -rw-r--r-- 988 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/* This testcase checks whether SWIG syntactically correctly parses the initialization syntax using
   {} braces for uniform member initialization. */
%module cpp11_uniform_initialization

%include <std_vector.i>

%template(VectorInt) std::vector<int>;

%inline %{
struct BasicStruct {
 int x;
 double y;
};
 
struct AltStruct {
  AltStruct(int x, double y) : x_{x}, y_{y} {}
  int getX() { return x_; }
  double getY() { return y_; }
 
private:
  int x_;
  double y_;
};
 
BasicStruct var1{5, 3.2}; // only fills the struct components
AltStruct var2{2, 4.3};   // calls the constructor

class MoreInit
{
public:
  int yarray[5] {1,2,3,4,5};
  char *charptr {nullptr};
  std::vector<int> vi {1,2,3,4,5};

  MoreInit() {}

  int more1(std::vector<int> vv = {1,2,3,4}) {
    int sum = 0;
    for (int i : vv)
      sum += i;
    return sum;
  }
};
const int arr1[] = {1,2,3};
const int arr2[]{1,2,3};
const int arr3[][3]{ {1,2,3}, {4,5,6} };
const int arr4[][3] = { {1,2,3}, {4,5,6} };
%}