summaryrefslogtreecommitdiff
path: root/test/CXX/temp/temp.decls/temp.variadic/sizeofpack.cpp
blob: 6a63b029de42836723e35293623c53cee2102bf5 (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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
// expected-no-diagnostics

namespace pr12262 {

template<typename T, typename... Ts>
void abc1(int (*xxx)[sizeof ... (Ts) + 1]);

void qq1 () {
  abc1<int>(0);
  abc1<int,double>(0);
}


template <unsigned N> class array {};


template<typename T, typename... Types>
array<sizeof...(Types)> make_array1(Types&&... args);

void qq2 () {
  array<1> arr = make_array1<int>(1);
  array<3> arr2 = make_array1<int>(1,array<5>(),0.1);
}


template<typename T, typename... Types>
int make_array(array<sizeof...(Types)>&, Types... args);

void qq3 () {
  array<1> a1;
  int aa1 = make_array<int>(a1,1);
  array<2> a2;
  int aa2 = make_array<int>(a2, 0L, "abc");
}


template<typename ... Ts>
struct AAA {
  template<typename T, typename... Types>
  static array<sizeof...(Types)> make_array(Types ... args);
};

void qq4 () {
  array<2> arr2 = AAA<int, int>::make_array<int>(1,2);
}

}


namespace pr12439 {

template<class... Members>
struct X {
  template<int Idx>
  using get_t = decltype(sizeof...(Members));

  template<int i>
  get_t<i> get();
};

template<class... Members>
template<int i>
X<Members...>::get_t<i> X<Members...>::get()
{
  return 0;
}

}


namespace pr13272 {

template<bool B, class T = void>
struct enable_if { };

template<class T> struct enable_if<true, T> {
  typedef T type;
};

class Exception {};

template<class Ex, typename... Args>
void cxx_throw(typename enable_if<(sizeof...(Args) > 0), const char *>::type fmt, Args&&... args) {
  return;
}

void test() {
  cxx_throw<Exception>("Youpi",1);
}

}


namespace pr13817 {

template <unsigned>
struct zod;

template <>
struct zod<1> {};

template <typename T, typename ... Ts>
zod<sizeof...(Ts)> make_zod(Ts ...) {
  return zod<sizeof...(Ts)>();
}

int main(int argc, char *argv[])
{
  make_zod<int>(1);
  return 0;
}

}


namespace pr14273 {

template<typename T, int i>
struct myType
{ };

template<typename T, typename... Args>
struct Counter
{
  static const int count = 1 + Counter<Args...>::count;
};

template<typename T>
struct Counter<T>
{
  static const int count = 1;
};

template<typename Arg, typename... Args>
myType<Arg, sizeof...(Args)>* make_array_with_type(const Args&... args)
{
  return 0;
}

void func(void)
{
  make_array_with_type<char>(1,2,3);
}

}


namespace pr15112
{
  template<bool, typename _Tp = void>
    struct enable_if
    { };
  template<typename _Tp>
    struct enable_if<true,_Tp>
    { typedef _Tp type; };

  typedef __typeof__(sizeof(int)) size_t;

  template <size_t n, typename T, typename... Args>
  struct is_array_of { static const bool value = true; };

  struct cpu { using value_type = void; };

  template <size_t Order, typename T>
  struct coords_alias { typedef T type; };

  template <size_t Order, typename MemoryTag>
  using coords = typename coords_alias<Order, MemoryTag>::type;

  template <typename MemTag, typename... Args>
  typename enable_if<is_array_of<sizeof...(Args), size_t, Args...>::value,
                     coords<sizeof...(Args), MemTag>>::type
    mkcoords(Args... args);

  auto c1 = mkcoords<cpu>(0ul, 0ul, 0ul);
}