summaryrefslogtreecommitdiff
path: root/clang/test/CXX/temp/temp.decls/temp.variadic/fixed-expansion.cpp
blob: fb727543efa5b81ed2b6175393ff79f018417ff9 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s

template<typename T, typename U> struct pair { };
template<typename ...Types> struct tuple { };

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 ExpandIntoFixed {
  template<typename T, 
           typename U, 
           typename V = pair<T, U>, 
           typename W = V*> 
  class X0 { };

  template<typename ...Ts>
  class X1 {
  public:
    typedef X0<Ts...> type;
  };

  static_assert(is_same<X1<int, int>::type, 
                        X0<int, int, pair<int, int>, pair<int, int>*>>::value,
                "fails with two default arguments");

  static_assert(is_same<X1<int, int, float>::type, 
                        X0<int, int, float, float*>>::value,
                "fails with one default argument");

  static_assert(is_same<X1<int, int, float, double>::type, 
                        X0<int, int, float, double>>::value,
                "fails with no default arguments");
}

namespace ExpandIntoFixedShifted {
  template<typename T, 
           typename U, 
           typename V = pair<T, U>, 
           typename W = V*> 
  class X0 { };

  template<typename ...Ts>
  class X1 {
  public:
    typedef X0<char, Ts...> type;
  };

  static_assert(is_same<X1<int>::type, 
                        X0<char, int, pair<char, int>, pair<char, int>*>>::value,
                "fails with two default arguments");

  static_assert(is_same<X1<int, float>::type, 
                        X0<char, int, float, float*>>::value,
                "fails with one default argument");

  static_assert(is_same<X1<int, float, double>::type, 
                        X0<char, int, float, double>>::value,
                "fails with no default arguments");
}

namespace Deduction {
  template <typename X, typename Y = double> struct Foo {};
  template <typename ...Args> tuple<Args...> &foo(Foo<Args...>);

  void call_foo(Foo<int, float> foo_if, Foo<int> foo_i) {
    tuple<int, float> &t1 = foo(foo_if);
    tuple<int, double> &t2 = foo(foo_i);
  }
}

namespace PR9021a {
  template<typename, typename> 
  struct A { };

  template<typename ...T>
  struct B { 
    A<T...> a1;
  };

  void test() {
    B<int, int> c;
  }
}

namespace PR9021b {
  template<class, class>
  struct t2
  {
    
  };
  
  template<template<class...> class M>
  struct m
  {
    template<class... B>
    using inner = M<B...>;
  };

  m<t2> sta2;
}

namespace PartialSpecialization {
  template<typename T, typename U, typename V = U>
  struct X0; // expected-note{{template is declared here}}

  template<typename ...Ts>
  struct X0<Ts...> {
  };

  X0<int> x0i; // expected-error{{too few template arguments for class template 'X0'}}
  X0<int, float> x0if;
  X0<int, float, double> x0ifd;
}

namespace FixedAliasTemplate {
  template<typename,typename,typename> struct S {};
  template<typename T, typename U> using U = S<T, int, U>;
  template<typename...Ts> U<Ts...> &f(U<Ts...>, Ts...);
  S<int, int, double> &s1 = f({}, 0, 0.0);
}