diff options
author | William S Fulton <wsf@fultondesigns.co.uk> | 2023-01-03 21:26:12 +0000 |
---|---|---|
committer | William S Fulton <wsf@fultondesigns.co.uk> | 2023-01-03 21:26:12 +0000 |
commit | cdc08c9325621587038a4e8f582c3adcfe5225e0 (patch) | |
tree | 258b70e1eec9fbb688b98b902e488476097de1ae /Examples/test-suite/cpp11_variadic_function_templates.i | |
parent | 20ff64217d4b4cd2bc3d07c276c1334cf9b415a8 (diff) | |
download | swig-cdc08c9325621587038a4e8f582c3adcfe5225e0.tar.gz |
Move variadic function template tests to separate testcase
Diffstat (limited to 'Examples/test-suite/cpp11_variadic_function_templates.i')
-rw-r--r-- | Examples/test-suite/cpp11_variadic_function_templates.i | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/Examples/test-suite/cpp11_variadic_function_templates.i b/Examples/test-suite/cpp11_variadic_function_templates.i new file mode 100644 index 000000000..f95c57a1a --- /dev/null +++ b/Examples/test-suite/cpp11_variadic_function_templates.i @@ -0,0 +1,82 @@ +%module cpp11_variadic_function_templates + +// Some tests for variadic function templates +%inline %{ +class A { +public: + A() { + a = 100; + } + virtual ~A() {} + int a; +}; + +class B { +public: + B() { + b = 200; + } + virtual ~B() {} + int b; +}; + +class C { +public: + C() { + c = 300; + } + virtual ~C() {} + int c; +}; + +class D { +public: + D() { + d = 400; + } + virtual ~D() {} + int d; +}; +%} + +// #1863 +%inline %{ +class Container { +public: +template<typename... Args> + static void notifyMyTypes(void (fn)(Args...)); // unconventional function (ptr) +template<typename... Args> + static void notifyMyTypesA(void (*fn)(Args...)) {} // conventional function ptr +template<typename... Args> + static void notifyMyTypesB(void fn(Args...)) {}; // unconventional function (ptr) +}; +%} +%{ +template<typename... Args> + void Container::notifyMyTypes(void (fn)(Args...)) {} + +// Explicit template instantiations +template void Container::notifyMyTypes<>(void (tt)()); +template void Container::notifyMyTypes<int>(void (tt)(int)); +template void Container::notifyMyTypes<int, double>(void (tt)(int, double)); +%} + +// Not supported (most vexing parse), see Extending.html#Extending_nn7 +//%template(ContainerNotifyMyTypes1) Container::notifyMyTypes<int>; +%template(ContainerNotifyMyTypesA1) Container::notifyMyTypesA<int>; +%template(ContainerNotifyMyTypesB1) Container::notifyMyTypesB<int>; + +// #1863 +%inline %{ +#include <type_traits> +class EmplaceContainer { +public: +template<typename T, typename... Args> +void emplace(Args &&... args) noexcept( + std::is_nothrow_constructible<T, Args &&...>::value) {} +}; +%} + +%template(emplace) EmplaceContainer::emplace<int,A>; +// TODO +//%template(emplace) EmplaceContainer::emplace<int,A,B,C>; |