]>
Commit | Line | Data |
---|---|---|
ac1a984a PC |
1 | // PR c++/63723 |
2 | // { dg-do compile { target c++11 } } | |
3 | ||
4 | template<typename Tp> Tp declval(); | |
5 | ||
6 | template<typename Tp, Tp v> | |
7 | struct integral_constant | |
8 | { | |
9 | static constexpr Tp value = v; | |
10 | typedef Tp value_type; | |
11 | typedef integral_constant<Tp, v> type; | |
12 | constexpr operator value_type() const { return value; } | |
13 | }; | |
14 | ||
15 | typedef integral_constant<bool, true> true_type; | |
16 | typedef integral_constant<bool, false> false_type; | |
17 | ||
18 | template <typename From, typename To> | |
19 | class is_list_convertible_helper | |
20 | { | |
21 | template <typename To2> | |
22 | static void requires_conversion(To2 t); | |
23 | ||
24 | template <typename From2, typename To2, | |
25 | typename = decltype(requires_conversion<To2>({declval<From2>()}))> | |
26 | static true_type helper(int); | |
27 | ||
28 | template <typename From2, typename To2> | |
29 | static false_type helper(...); | |
30 | ||
31 | public: | |
32 | using type = decltype(helper<From, To>(0)); | |
33 | }; | |
34 | ||
35 | template <typename From, typename To> | |
36 | class is_list_convertible | |
37 | : public is_list_convertible_helper<From, To>::type | |
38 | { }; | |
39 | ||
40 | static_assert(!is_list_convertible<double, int>::value, | |
41 | "double -> int is narrowing!"); |