diff options
Diffstat (limited to 'Examples/test-suite/cpp11_default_delete.i')
-rw-r--r-- | Examples/test-suite/cpp11_default_delete.i | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/Examples/test-suite/cpp11_default_delete.i b/Examples/test-suite/cpp11_default_delete.i index 0c20fb7ee..408027c4b 100644 --- a/Examples/test-suite/cpp11_default_delete.i +++ b/Examples/test-suite/cpp11_default_delete.i @@ -57,9 +57,34 @@ struct sometype { sometype() = delete; sometype(int) = delete; sometype(double); + static sometype make(double d) { return sometype(d); } + static void take(sometype s) {} }; sometype::sometype(double) {} +struct sometype2 { + sometype2() = delete; + sometype2(double) {} + static sometype2 make(double d) { return sometype2(d); } + static void take(sometype2 s) {} +}; + +struct sometype3 { + int num; +#if __cplusplus >= 202002L + // Uniform/aggregate initialization was removed in C++20 if there is a user declared constructor, so the initialization in make() below does not work + // This example can only be tested for C++11 to C++17, in C++20 the constructor declaration is removed by making it an aggregate + // SWIG still sees the deleted constructor below +#else + sometype3() = delete; +#endif + static sometype3 make(int n) { + // Note: Can only be constructed via copy constructor, so use C++11 uniform initialization to create + return sometype3 {n}; + } + static void take(sometype3 s) {} +}; + /* Not working with prerelease of gcc-4.8 struct nonew { void *operator new(std::size_t) = delete; |