c++: prvalue of array type [PR111286]
[official-gcc.git] / gcc / testsuite / g++.dg / cpp0x / sfinae66.C
blob49067cd35d0fb452b1a53efce665b3665437d904
1 // PR c++/95143
2 // { dg-do compile { target c++11 } }
4 struct false_type {
5   static constexpr bool value = false;
6 };
8 struct true_type{
9   static constexpr bool value = true;
12 template<class T>
13 T&& declval() noexcept;
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 {};
22 class Base { };
23 struct A { };
24 class B: public Base { };
26 int main()
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, "");