aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp2a/is-layout-compatible2.C
blob: bf902f385a500417591b04b2fddc6b515df780a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// P0466R5
// { dg-do compile { target c++20 } }

namespace std
{
template <typename T, T v>
struct integral_constant
{
  static constexpr T value = v;
};

template <typename, typename>
struct is_layout_compatible;

template<typename T, typename U>
struct is_layout_compatible
  : public integral_constant <bool, __is_layout_compatible (T, U)>
{
};

template <typename T, typename U>
inline constexpr bool is_layout_compatible_v = __is_layout_compatible (T, U);
}
// { dg-error "invalid use of incomplete type 'struct W'" "" { target *-*-* } .-2 }
// { dg-error "invalid use of incomplete type 'struct \[XY]'" "" { target *-*-* } .-3 }
// { dg-error "invalid use of incomplete type 'struct Z'" "" { target *-*-* } .-4 }

struct W;
struct X;
struct Y;
struct Z;
struct A {};

auto a = std::is_layout_compatible_v<W, W>;
auto b = std::is_layout_compatible_v<X, Y>;
auto c = std::is_layout_compatible_v<A, Z>;