Skip to content

Commit f651890

Browse files
test: Add more complex test cases for templates (#137)
1 parent d304f47 commit f651890

File tree

2 files changed

+78
-0
lines changed

2 files changed

+78
-0
lines changed

test/index/types/templates.cc

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,30 @@ F<B> fmap(A f(B), F<A> fa) {
1212

1313
template <int N>
1414
void f(int arr[N]) {}
15+
16+
template <typename... Bs, template <typename...> typename... As>
17+
void g(As<Bs...> ...) {}
18+
19+
template <typename T>
20+
struct PointerType {
21+
using type = T *;
22+
};
23+
24+
template <typename T>
25+
struct PointerType<T &> {
26+
using type = T *;
27+
};
28+
29+
template <typename T>
30+
using RefPtr = typename PointerType<T &>::type;
31+
32+
using IntRefPtr = RefPtr<int>;
33+
34+
template <typename T>
35+
using PtrPtr = typename PointerType<T *>::type;
36+
37+
template <typename T, typename S = typename PointerType<T>::type>
38+
void specialized(T) {}
39+
40+
template <>
41+
void specialized<int, int>(int) {}

test/index/types/templates.snapshot.cc

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,54 @@
3535
// ^ definition [..] f(11b0e290e57a7e53).
3636
// ^^^ definition local 8
3737
// ^ reference local 7
38+
39+
template <typename... Bs, template <typename...> typename... As>
40+
// ^^ definition local 9
41+
// ^^ definition local 10
42+
void g(As<Bs...> ...) {}
43+
// ^ definition [..] g(c3d59a70a6e5360c).
44+
// ^^ reference local 10
45+
// ^^ reference local 9
46+
47+
template <typename T>
48+
// ^ definition local 11
49+
struct PointerType {
50+
// ^^^^^^^^^^^ definition [..] PointerType#
51+
using type = T *;
52+
// ^^^^ definition [..] PointerType#type#
53+
// ^ reference local 11
54+
};
55+
56+
template <typename T>
57+
// ^ definition local 12
58+
struct PointerType<T &> {
59+
// ^^^^^^^^^^^ definition [..] PointerType#
60+
// ^ reference local 12
61+
using type = T *;
62+
// ^^^^ definition [..] PointerType#type#
63+
// ^ reference local 12
64+
};
65+
66+
template <typename T>
67+
// ^ definition local 13
68+
using RefPtr = typename PointerType<T &>::type;
69+
// ^^^^^^ definition [..] RefPtr#
70+
71+
using IntRefPtr = RefPtr<int>;
72+
// ^^^^^^^^^ definition [..] IntRefPtr#
73+
74+
template <typename T>
75+
// ^ definition local 14
76+
using PtrPtr = typename PointerType<T *>::type;
77+
// ^^^^^^ definition [..] PtrPtr#
78+
79+
template <typename T, typename S = typename PointerType<T>::type>
80+
// ^ definition local 15
81+
// ^ definition local 16
82+
void specialized(T) {}
83+
// ^^^^^^^^^^^ definition [..] specialized(9b289cee16747614).
84+
// ^ reference local 15
85+
86+
template <>
87+
void specialized<int, int>(int) {}
88+
// ^^^^^^^^^^^ definition [..] specialized(d4f767463ce0a6b3).

0 commit comments

Comments
 (0)