111
|
1 // PR c++/65133
|
|
2 // { dg-do compile { target c++11 } }
|
|
3
|
|
4 template<bool, typename Tp = void>
|
|
5 struct enable_if { };
|
|
6
|
|
7 template<typename Tp>
|
|
8 struct enable_if<true, Tp> { typedef Tp type; };
|
|
9
|
|
10 template <int I>
|
|
11 struct count
|
|
12 {
|
|
13 using type = typename count<I-1>::type;
|
|
14 };
|
|
15
|
|
16 template <>
|
|
17 struct count<0>
|
|
18 {
|
|
19 using type = void;
|
|
20 };
|
|
21
|
|
22 template <int I>
|
|
23 auto foo(typename enable_if<(I>=0)>::type *
|
|
24 = nullptr) -> typename count<I>::type { }
|
|
25
|
|
26 template <int I>
|
|
27 void foo(typename enable_if<(I<0)>::type * = nullptr) { }
|
|
28
|
|
29 int main()
|
|
30 {
|
|
31 foo<2>();
|
|
32 foo<-1>();
|
|
33 }
|