Move variadic function template tests to separate testcase
This commit is contained in:
parent
20ff64217d
commit
cdc08c9325
3 changed files with 83 additions and 43 deletions
|
|
@ -632,6 +632,7 @@ CPP11_TEST_CASES += \
|
||||||
cpp11_uniform_initialization \
|
cpp11_uniform_initialization \
|
||||||
cpp11_unrestricted_unions \
|
cpp11_unrestricted_unions \
|
||||||
cpp11_userdefined_literals \
|
cpp11_userdefined_literals \
|
||||||
|
cpp11_variadic_function_templates \
|
||||||
cpp11_variadic_templates \
|
cpp11_variadic_templates \
|
||||||
|
|
||||||
# Broken C++11 test cases.
|
# Broken C++11 test cases.
|
||||||
|
|
|
||||||
82
Examples/test-suite/cpp11_variadic_function_templates.i
Normal file
82
Examples/test-suite/cpp11_variadic_function_templates.i
Normal file
|
|
@ -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>;
|
||||||
|
|
@ -218,46 +218,3 @@ public:
|
||||||
%template(FixedAndVariadicParms1) FixedAndVariadicParms<A>;
|
%template(FixedAndVariadicParms1) FixedAndVariadicParms<A>;
|
||||||
%template(FixedAndVariadicParms2) FixedAndVariadicParms<A,B>;
|
%template(FixedAndVariadicParms2) FixedAndVariadicParms<A,B>;
|
||||||
%template(FixedAndVariadicParms3) FixedAndVariadicParms<A,B,C>;
|
%template(FixedAndVariadicParms3) FixedAndVariadicParms<A,B,C>;
|
||||||
|
|
||||||
|
|
||||||
// #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>;
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue