| 1 |
// { dg-do compile { target c++11 } } |
| 2 |
template<typename _Tp> |
| 3 |
_Tp&& declval() noexcept; |
| 4 |
|
| 5 |
template<bool b> |
| 6 |
struct bt { |
| 7 |
static constexpr bool value = b; |
| 8 |
}; |
| 9 |
|
| 10 |
template <typename To_, typename... From_> |
| 11 |
class my_is_convertible_many { |
| 12 |
private: |
| 13 |
template <typename To> |
| 14 |
struct indirector { |
| 15 |
indirector(To); |
| 16 |
}; |
| 17 |
|
| 18 |
template <typename To, typename... From> |
| 19 |
struct tag {}; |
| 20 |
|
| 21 |
template <typename To, typename... From> |
| 22 |
static auto test(tag<To, From...>) |
| 23 |
-> decltype(indirector<To>({declval<From>()...}), bt<true>()); |
| 24 |
static auto test(...) |
| 25 |
-> bt<false>; |
| 26 |
|
| 27 |
public: |
| 28 |
static constexpr bool value = decltype(test(tag<To_, From_...>()))::value; |
| 29 |
}; |
| 30 |
|
| 31 |
struct A {}; |
| 32 |
struct B {}; |
| 33 |
struct C {}; |
| 34 |
|
| 35 |
struct Test { |
| 36 |
Test(A, A); |
| 37 |
//Test(B, B); |
| 38 |
explicit Test(C, C); |
| 39 |
}; |
| 40 |
|
| 41 |
int main() { |
| 42 |
static_assert(my_is_convertible_many<Test, A, A>::value,""); // true, correct |
| 43 |
static_assert(!my_is_convertible_many<Test, B, B>::value,""); // false, correct |
| 44 |
static_assert(!my_is_convertible_many<Test, C, C>::value,""); // error |
| 45 |
return 0; |
| 46 |
} |