mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
This makes sure that different template instantiations of `std::tuple` get distinct Swift type names.
Similar to aa6804a3.
This also refactors `swift::importer::printClassTemplateSpecializationName` to follow a proper visitor pattern for the C++ template arguments.
rdar://139435937
34 lines
869 B
C++
34 lines
869 B
C++
#ifndef TEST_INTEROP_CXX_TEMPLATES_INPUTS_CLASS_TEMPLATE_VARIADIC_H
|
|
#define TEST_INTEROP_CXX_TEMPLATES_INPUTS_CLASS_TEMPLATE_VARIADIC_H
|
|
|
|
template <class... Ts> struct Tuple {};
|
|
|
|
template <>
|
|
struct Tuple<> {
|
|
void set() {}
|
|
};
|
|
|
|
template <class T, class... Ts>
|
|
struct Tuple<T, Ts...> : Tuple<Ts...> {
|
|
Tuple(T t, Ts... ts) : Tuple<Ts...>(ts...), _t(t) {}
|
|
|
|
void set(T t, Ts... ts) { _t = t; Tuple<Ts...>::set(ts...); }
|
|
|
|
T first() { return _t; }
|
|
Tuple<Ts...> rest() { return *this; }
|
|
|
|
T _t;
|
|
};
|
|
|
|
struct IntWrapper {
|
|
int value;
|
|
int getValue() const { return value; }
|
|
};
|
|
|
|
typedef Tuple<IntWrapper> Single;
|
|
typedef Tuple<IntWrapper, IntWrapper> Pair;
|
|
typedef Tuple<IntWrapper, IntWrapper, IntWrapper> Triple;
|
|
typedef Tuple<Tuple<IntWrapper, IntWrapper>, Tuple<IntWrapper, IntWrapper>> Nested;
|
|
|
|
#endif // TEST_INTEROP_CXX_TEMPLATES_INPUTS_CLASS_TEMPLATE_VARIADIC_H
|