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