blob: af3b93c907c1418ff48fcf9bcc04b407c9b4276f [file] [log] [blame]
Douglas Gregor67714232011-03-03 02:41:12 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s
2
3// Core issue 150: Template template parameters and default arguments
4
Douglas Gregor9a299e02011-03-04 17:52:15 +00005template<typename T, typename U>
6struct is_same {
7 static const bool value = false;
8};
9
10template<typename T>
11struct is_same<T, T> {
12 static const bool value = true;
13};
14
Douglas Gregor67714232011-03-03 02:41:12 +000015namespace PR9353 {
16 template<class _T, class Traits> class IM;
17
18 template <class T, class Trt,
19 template<class _T, class Traits = int> class IntervalMap>
20 void foo(IntervalMap<T,Trt>* m) { typedef IntervalMap<int> type; }
21
22 void f(IM<int, int>* m) { foo(m); }
23}
Douglas Gregor9a299e02011-03-04 17:52:15 +000024
25namespace PR9400 {
26 template<template <typename T, typename = T > class U> struct A
27 {
28 template<int> U<int> foo();
29 };
30
31 template <typename T, typename = T>
32 struct s {
33 };
34
35 void f() {
36 A<s> x;
37 x.foo<2>();
38 }
39}
40
41namespace MultiReplace {
42 template<typename Z,
43 template<typename T, typename U = T *, typename V = U const> class TT>
44 struct X {
45 typedef TT<Z> type;
46 };
47
48 template<typename T, typename = int, typename = float>
49 struct Y { };
50
51 int check0[is_same<X<int, Y>::type, Y<int, int*, int* const> >::value? 1 : -1];
52}
53
54namespace MultiReplacePartial {
55 template<typename First, typename Z,
56 template<typename T, typename U = T *, typename V = U const> class TT>
57 struct X {
58 typedef TT<Z> type;
59 };
60
61 template<typename Z,
62 template<typename T, typename U = T *, typename V = U const> class TT>
63 struct X<int, Z, TT> {
64 typedef TT<Z> type;
65 };
66
67 template<typename T, typename = int, typename = float>
68 struct Y { };
69
70 int check0[is_same<X<int, int, Y>::type, Y<int, int*, int* const> >::value? 1 : -1];
71}
Douglas Gregor0b4bcb62011-03-05 17:19:27 +000072
73namespace PR9016 {
74 template<typename > struct allocator ;
75 template<typename > struct less ;
76
77 template<class T, template<class> class Compare, class Default,
78 template<class> class Alloc>
79 struct interval_set { };
80
81 template <class X, template<class> class = less> struct interval_type_default {
82 typedef X type;
83 };
84
85 template <class T,
Douglas Gregor58750382011-03-05 20:06:51 +000086 template<class _T, template<class> class Compare = PR9016::less,
Douglas Gregor0b4bcb62011-03-05 17:19:27 +000087 class = typename interval_type_default<_T,Compare>::type,
88 template<class> class = allocator> class IntervalSet>
89 struct ZZZ
90 {
91 IntervalSet<T> IntervalSetT;
92 };
93
Douglas Gregorc494f772011-03-05 17:54:25 +000094 template <class T,
Douglas Gregor58750382011-03-05 20:06:51 +000095 template<class _T, template<class> class Compare = PR9016::less,
Douglas Gregorc494f772011-03-05 17:54:25 +000096 class = typename interval_type_default<_T,Compare>::type,
97 template<class> class = allocator> class IntervalSet>
98 void int40()
99 {
100 IntervalSet<T> IntervalSetT;
101 }
102
Douglas Gregor0b4bcb62011-03-05 17:19:27 +0000103 void test() {
104 ZZZ<int, interval_set> zzz;
Douglas Gregorc494f772011-03-05 17:54:25 +0000105 int40<int, interval_set>();
Douglas Gregor0b4bcb62011-03-05 17:19:27 +0000106 }
107}