template<typename... Types> struct tuple;
template<int I> struct int_c;
template<typename T>
struct identity {
typedef T type;
};
template<typename T, typename U>
struct is_same {
static const bool value = false;
};
template<typename T>
struct is_same<T, T> {
static const bool value = true;
};
namespace PR11850 {
template<typename ...T> struct S {
int f(T...a, int b) { return b; }
};
S<> s;
S<int*, char, const double&> t;
int k = s.f(0);
int l = t.f(&k, 'x', 5.9, 4);
template<typename ...As> struct A {
template<typename ...Bs> struct B {
template<typename ...Cs> struct C {
C(As..., Bs..., int &k, Cs...);
};
};
};
A<>::B<>::C<> c000(k);
A<int>::B<>::C<int> c101(1, k, 3);
A<>::B<int>::C<int> c011(1, k, 3);
A<int>::B<int>::C<> c110(1, 2, k);
A<int, int>::B<int, int>::C<int, int> c222(1, 2, 3, 4, k, 5, 6);
A<int, int, int>::B<>::C<> c300(1, 2, 3, k);
int &f();
char &f(void*);
template<typename ...A> struct U {
template<typename ...B> struct V {
auto g(A...a, B...b) -> decltype(f(a...));
};
};
U<>::V<int*> v0;
U<int*>::V<> v1;
int &v0f = v0.g(0);
char &v1f = v1.g(0);
}
namespace PR12096 {
void Foo(int) {}
void Foo(int, int) = delete;
template<typename ...Args> struct Var {
Var(const Args &...args, int *) { Foo(args...); }
};
Var<int> var(1, 0);
}
void five_args(int, int, int, int, int);
template<int ...Values>
void initializer_list_expansion() {
int values[5] = { Values... }; five_args(Values...); }
template void initializer_list_expansion<1, 2, 3, 4, 5>();
template void initializer_list_expansion<1, 2, 3, 4, 5, 6>();
namespace PR8977 {
struct A { };
template<typename T, typename... Args> void f(Args... args) {
constexpr T t(args...);
};
template void f<A>();
}
template<typename ...Mixins>
struct HasMixins : public Mixins... {
HasMixins();
HasMixins(const HasMixins&);
HasMixins(int i);
};
struct A { }; struct B { }; struct C { };
struct D { };
A *checkA = new HasMixins<A, B, C, D>;
B *checkB = new HasMixins<A, B, C, D>;
D *checkD = new HasMixins<A, B, C, D>;
C *checkC = new HasMixins<A, B, D>; HasMixins<> *checkNone = new HasMixins<>;
template<typename Mixins>
struct BrokenMixins : public Mixins... { };
template<typename ...Mixins>
HasMixins<Mixins...>::HasMixins(): Mixins()... { }
template<typename ...Mixins>
HasMixins<Mixins...>::HasMixins(const HasMixins &other): Mixins(other)... { }
template<typename ...Mixins>
HasMixins<Mixins...>::HasMixins(int i): Mixins(i)... { }
void test_has_mixins() {
HasMixins<A, B> ab;
HasMixins<A, B> ab2 = ab;
HasMixins<A, B> ab3(17); }
template<typename T>
struct X {
T member;
X() : member()... { } };
template<typename ...T>
struct DelayedParseTest : T...
{
int a;
DelayedParseTest(T... i) : T{i}..., a{10} {}
};
template<typename ...Types>
struct tuple_of_refs {
typedef tuple<Types& ...> types;
};
tuple<int&, float&> *t_int_ref_float_ref;
tuple_of_refs<int&, float&>::types *t_int_ref_float_ref_2 = t_int_ref_float_ref;
template<typename ...Types>
struct extract_nested_types {
typedef tuple<typename Types::type...> types;
};
tuple<int, float> *t_int_float;
extract_nested_types<identity<int>, identity<float> >::types *t_int_float_2
= t_int_float;
template<int ...N>
struct tuple_of_ints {
typedef tuple<int_c<N>...> type;
};
int check_temp_arg_1[is_same<tuple_of_ints<1, 2, 3, 4, 5>::type,
tuple<int_c<1>, int_c<2>, int_c<3>, int_c<4>,
int_c<5>>>::value? 1 : -1];
#if __cplusplus < 201703L
template<typename ...Types>
struct f_with_except {
virtual void f() throw(Types...); };
struct check_f_with_except_1 : f_with_except<int, float> {
virtual void f() throw(int, float);
};
struct check_f_with_except_2 : f_with_except<int, float> {
virtual void f() throw(int);
};
struct check_f_with_except_3 : f_with_except<int, float> {
virtual void f() throw(int, float, double); };
#endif
namespace PackExpansionWithinLambda {
void swallow(...);
template<typename ...T, typename ...U> void f(U ...u) {
swallow([=] {
void g(T...);
#if __cplusplus >= 201703L
struct A : T... {
using T::x...;
using typename T::U...;
};
#endif
#if __cplusplus > 201703L
swallow([]<T *...v, template<T *> typename ...W>(W<v> ...wv) { });
#endif
int arr[] = {T().x...};
struct B : T... {
B() : T{0}... {}
};
f<T...>();
alignas(T...) int y;
[](T ...t) { [t...]{}(); } (T()...);
const int k1 = sizeof...(T);
#if __cplusplus >= 201703L
const int k2 = ((sizeof(T)/sizeof(T)) + ...);
static_assert(k1 == k2);
#endif
U u;
} ...);
}
template<typename ...T> void nested() {
swallow([=] {
[](T ...t) { [t]{}(); } (T()...); }...); }
template <typename ...T> void g() {
swallow([=] { void h(T); }); swallow([=] { struct A : T {}; }); #if __cplusplus >= 201703L
swallow([=] { struct A : T... { using T::x; }; }); swallow([=] { struct A : T... { using typename T::U; }; }); #endif
swallow([=] { int arr[] = {T().x}; }); swallow([=] { struct B : T... { B() : T{0} {} }; }); swallow([=] { f<T>(); }); swallow([=] { alignas(T) int y; }); swallow([=] { [](T ...t) {
[t]{}(); } (T()...); });
}
struct T { int x; using U = int; };
void g() { f<T>(1, 2, 3); }
template<typename ...T> void pack_expand_attr() {
[[gnu::aligned(alignof(T))...]] int x; }
}