Mercurial > hg > CbC > CbC_gcc
comparison gcc/testsuite/g++.dg/cpp0x/sfinae66.C @ 152:2b5abeee2509
update gcc11
author | anatofuz |
---|---|
date | Mon, 25 May 2020 07:50:57 +0900 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
145:1830386684a0 | 152:2b5abeee2509 |
---|---|
1 // PR c++/95143 | |
2 // { dg-do compile { target c++11 } } | |
3 | |
4 struct false_type { | |
5 static constexpr bool value = false; | |
6 }; | |
7 | |
8 struct true_type{ | |
9 static constexpr bool value = true; | |
10 }; | |
11 | |
12 template<class T> | |
13 T&& declval() noexcept; | |
14 | |
15 template<typename T, typename U, typename = U> | |
16 struct is_static_castable : false_type | |
17 {}; | |
18 template<typename T, typename U> | |
19 struct is_static_castable<T, U, decltype(static_cast<U>(declval<T>()))> : true_type | |
20 {}; | |
21 | |
22 class Base { }; | |
23 struct A { }; | |
24 class B: public Base { }; | |
25 | |
26 int main() | |
27 { | |
28 constexpr auto canCast = is_static_castable<A, B>::value; | |
29 static_assert(!canCast, ""); | |
30 constexpr auto canCast2 = is_static_castable<A, A>::value; | |
31 static_assert(canCast2, ""); | |
32 } |