1 | // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s |
2 | // expected-no-diagnostics |
3 | |
4 | namespace ParameterPacksWithFunctions { |
5 | template<typename ...> struct count; |
6 | |
7 | template<typename Head, typename ...Tail> |
8 | struct count<Head, Tail...> { |
9 | static const unsigned value = 1 + count<Tail...>::value; |
10 | }; |
11 | |
12 | template<> |
13 | struct count<> { |
14 | static const unsigned value = 0; |
15 | }; |
16 | |
17 | template<unsigned> struct unsigned_c { }; |
18 | |
19 | template<typename ... Types> |
20 | unsigned_c<count<Types...>::value> f(); |
21 | |
22 | void test_f() { |
23 | unsigned_c<0> uc0a = f(); // okay, deduced to an empty pack |
24 | unsigned_c<0> uc0b = f<>(); |
25 | unsigned_c<1> uc1 = f<int>(); |
26 | unsigned_c<2> uc2 = f<float, double>(); |
27 | } |
28 | } |
29 | |
30 | namespace rdar12176336 { |
31 | typedef void (*vararg_func)(...); |
32 | |
33 | struct method { |
34 | vararg_func implementation; |
35 | |
36 | method(vararg_func implementation) : implementation(implementation) {} |
37 | |
38 | template<typename TReturnType, typename... TArguments, typename TFunctionType = TReturnType (*)(TArguments...)> |
39 | auto getImplementation() const -> TFunctionType |
40 | { |
41 | return reinterpret_cast<TFunctionType>(implementation); |
42 | } |
43 | }; |
44 | |
45 | void f() { |
46 | method m(nullptr); |
47 | auto imp = m.getImplementation<int, int, int>(); |
48 | } |
49 | } |
50 | |