aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite/20_util/monostate/requirements.cc
blob: c385862c8857a0611068089a0a24dc42a6d04cbd (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
37
38
// { dg-do compile { target c++17 } }

#if __cplusplus <= 202302L
# include <variant>
#else
# include <utility>
#endif

void
test01()
{
  static_assert( std::is_nothrow_default_constructible_v<std::monostate> );
  static_assert( std::is_nothrow_copy_constructible_v<std::monostate> );
  static_assert( std::is_nothrow_copy_assignable_v<std::monostate> );
  static_assert( std::is_nothrow_destructible_v<std::monostate> );
}

void
test02()
{
#ifdef __cpp_lib_three_way_comparison
  static_assert( std::is_eq(std::monostate{} <=> std::monostate{}) );
#endif
  static_assert( std::monostate{} == std::monostate{} );
  static_assert( std::monostate{} <= std::monostate{} );
  static_assert( std::monostate{} >= std::monostate{} );
  static_assert( !(std::monostate{} != std::monostate{}) );
  static_assert( !(std::monostate{} < std::monostate{}) );
  static_assert( !(std::monostate{} > std::monostate{}) );
}

void
test03()
{
  std::monostate m;
  std::hash<std::monostate> h;
  static_assert( std::is_same_v<decltype(h(m)), std::size_t> );
}