diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index cb71aab1b..b1f032641 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -632,6 +632,7 @@ CPP11_TEST_CASES += \ cpp11_uniform_initialization \ cpp11_unrestricted_unions \ cpp11_userdefined_literals \ + cpp11_variadic_function_templates \ cpp11_variadic_templates \ # Broken C++11 test cases. 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 + static void notifyMyTypes(void (fn)(Args...)); // unconventional function (ptr) +template + static void notifyMyTypesA(void (*fn)(Args...)) {} // conventional function ptr +template + static void notifyMyTypesB(void fn(Args...)) {}; // unconventional function (ptr) +}; +%} +%{ +template + void Container::notifyMyTypes(void (fn)(Args...)) {} + +// Explicit template instantiations +template void Container::notifyMyTypes<>(void (tt)()); +template void Container::notifyMyTypes(void (tt)(int)); +template void Container::notifyMyTypes(void (tt)(int, double)); +%} + +// Not supported (most vexing parse), see Extending.html#Extending_nn7 +//%template(ContainerNotifyMyTypes1) Container::notifyMyTypes; +%template(ContainerNotifyMyTypesA1) Container::notifyMyTypesA; +%template(ContainerNotifyMyTypesB1) Container::notifyMyTypesB; + +// #1863 +%inline %{ +#include +class EmplaceContainer { +public: +template +void emplace(Args &&... args) noexcept( + std::is_nothrow_constructible::value) {} +}; +%} + +%template(emplace) EmplaceContainer::emplace; +// TODO +//%template(emplace) EmplaceContainer::emplace; diff --git a/Examples/test-suite/cpp11_variadic_templates.i b/Examples/test-suite/cpp11_variadic_templates.i index 008539393..1caf82463 100644 --- a/Examples/test-suite/cpp11_variadic_templates.i +++ b/Examples/test-suite/cpp11_variadic_templates.i @@ -218,46 +218,3 @@ public: %template(FixedAndVariadicParms1) FixedAndVariadicParms; %template(FixedAndVariadicParms2) FixedAndVariadicParms; %template(FixedAndVariadicParms3) FixedAndVariadicParms; - - -// #1863 -%inline %{ -class Container { -public: -template - static void notifyMyTypes(void (fn)(Args...)); // unconventional function (ptr) -template - static void notifyMyTypesA(void (*fn)(Args...)) {} // conventional function ptr -template - static void notifyMyTypesB(void fn(Args...)) {}; // unconventional function (ptr) -}; -%} -%{ -template - void Container::notifyMyTypes(void (fn)(Args...)) {} - -// Explicit template instantiations -template void Container::notifyMyTypes<>(void (tt)()); -template void Container::notifyMyTypes(void (tt)(int)); -template void Container::notifyMyTypes(void (tt)(int, double)); -%} - -// Not supported (most vexing parse), see Extending.html#Extending_nn7 -//%template(ContainerNotifyMyTypes1) Container::notifyMyTypes; -%template(ContainerNotifyMyTypesA1) Container::notifyMyTypesA; -%template(ContainerNotifyMyTypesB1) Container::notifyMyTypesB; - -// #1863 -%inline %{ -#include -class EmplaceContainer { -public: -template -void emplace(Args &&... args) noexcept( - std::is_nothrow_constructible::value) {} -}; -%} - -%template(emplace) EmplaceContainer::emplace; -// TODO -//%template(emplace) EmplaceContainer::emplace;