File: cpp11_default_delete.i

package info (click to toggle)
swig 4.0.2-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 42,876 kB
  • sloc: cpp: 61,013; ansic: 27,612; java: 14,670; python: 10,632; cs: 8,103; makefile: 6,287; yacc: 6,197; sh: 5,247; ruby: 5,172; perl: 3,541; php: 2,069; ml: 2,066; lisp: 1,894; javascript: 1,300; tcl: 1,091; xml: 115
file content (87 lines) | stat: -rw-r--r-- 2,469 bytes parent folder | download | duplicates (2)
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/* This testcase checks whether SWIG correctly parses C++11 explicitly defaulted functions and deleted functions */
%module cpp11_default_delete

%warnfilter(SWIGWARN_LANG_OVERLOAD_IGNORED, SWIGWARN_LANG_OVERLOAD_SHADOW) trivial::trivial(trivial&&);
%warnfilter(SWIGWARN_LANG_OVERLOAD_IGNORED, SWIGWARN_LANG_OVERLOAD_SHADOW) trivial::operator =(trivial&&);

%rename(Assignment) *::operator=;

%inline %{

class NonCopyable {
public:
  NonCopyable& operator=(const NonCopyable&) = delete; /* Removes operator= */
  NonCopyable(const NonCopyable&) = delete; /* Removed copy constructor */
  NonCopyable() = default; /* Explicitly allows the empty constructor */
  void *operator new(size_t) = delete; /* Removes new NonCopyable */
};

struct A1 {
  void funk(int i) {}
  A1() = default;
  ~A1() = default;
  void funk(double i) = delete;  /* Don't cast double to int. Compiler returns an error */
private:
  A1(const A1&);
};
A1::A1(const A1&) = default;

struct A2 {
  void funk(int i) {}

// Workaround clang 10.0.1 -std=c++17 linker error (oddly for Java and not Python):
// Undefined symbols for architecture x86_64:"___cxa_deleted_virtual", referenced from: vtable for A2
#if !(defined(__clang__) && __cplusplus >= 201703L)
  virtual void fff(int) = delete;
#endif

  virtual ~A2() = default;
  template<class T> void funk(T) = delete;
};

struct trivial {
  trivial() = default;
  trivial(const trivial&) = default;
  trivial(trivial&&) = default;
  trivial& operator=(const trivial&) = default;
  trivial& operator=(trivial&&) = default;
  ~trivial() = default;
};

struct nontrivial1 {
  nontrivial1();
};
nontrivial1::nontrivial1() = default;

struct sometype {
  sometype() = delete;
  sometype(int) = delete;
  sometype(double);
};
sometype::sometype(double) {}

/* Not working with prerelease of gcc-4.8
struct nonew {
  void *operator new(std::size_t) = delete;
  void *operator new[](std::size_t) = delete;
};
*/

struct moveonly {
  moveonly() = default;
  moveonly(const moveonly&) = delete;
  moveonly(moveonly&&) = default;
  moveonly& operator=(const moveonly&) = delete;
  moveonly& operator=(moveonly&&) = default;
  ~moveonly() = default;
};

struct ConstructorThrow {
  ConstructorThrow() throw() = default;
  ConstructorThrow(const ConstructorThrow&) throw() = delete;
  ConstructorThrow(ConstructorThrow&&) throw() = delete;
  ConstructorThrow& operator=(const ConstructorThrow&) throw() = delete;
  ~ConstructorThrow() throw() = default;
};

%}