aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp23/explicit-obj-ops-non-mem-non-dep.C
blob: 634e878c93e1f21aaa858960304918d2eddbb531 (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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// P0847R7
// { dg-do compile { target c++23 } }

// operators that are not required to be members
// called in a non-dependent context
// see header
#include "explicit-obj-ops-non-mem.h"

// noop, indicates which versions are ill-formed
// I could not find a way to test the invalid cases
// without requires expressions
#define TEST_INVALID(X)

void do_calls()
{
  Value value{};
  TEST_OPS(value)
  TEST_OPS(static_cast<Value&&>(value))
  TEST_OPS(static_cast<Value const&>(value))
  TEST_OPS(static_cast<Value const&&>(value))
  
  LRef l_ref{};
  TEST_OPS(l_ref)
  TEST_INVALID(static_cast<LRef&&>(l_ref))
  TEST_INVALID(static_cast<LRef const&>(l_ref))
  TEST_INVALID(static_cast<LRef const&&>(l_ref))

  RRef r_ref{};
  TEST_INVALID(r_ref)
  TEST_OPS(static_cast<RRef&&>(r_ref))
  TEST_INVALID(static_cast<RRef const&>(r_ref))
  TEST_INVALID(static_cast<RRef const&&>(r_ref))

  ConstLRef const_l_ref{};
  TEST_OPS(const_l_ref)
  TEST_OPS(static_cast<ConstLRef&&>(const_l_ref))
  TEST_OPS(static_cast<ConstLRef const&>(const_l_ref))
  TEST_OPS(static_cast<ConstLRef const&&>(const_l_ref))

  ConstRRef const_r_ref{};
  TEST_INVALID(const_r_ref)
  TEST_OPS(static_cast<ConstRRef&&>(const_r_ref))
  TEST_INVALID(static_cast<ConstRRef const&>(const_r_ref))
  TEST_OPS(static_cast<ConstRRef const&&>(const_r_ref))

  Deduced deduced{};
  TEST_OPS(deduced)
  TEST_OPS(static_cast<Deduced&&>(deduced))
  TEST_OPS(static_cast<Deduced const&>(deduced))
  TEST_OPS(static_cast<Deduced const&&>(deduced))

  VALIDATE_RETURN_TYPES(deduced, Deduced&)
  VALIDATE_RETURN_TYPES(static_cast<Deduced&&>(deduced), Deduced&&)
  VALIDATE_RETURN_TYPES(static_cast<Deduced const&>(deduced), Deduced const&)
  VALIDATE_RETURN_TYPES(static_cast<Deduced const&&>(deduced), Deduced const&&)
}