| 131 | }; |
| 132 | |
| 133 | void DoTests() |
| 134 | { |
| 135 | // Callable::OverloadSet can capture many kinds of things. Test each. |
| 136 | // This also tests compilation of the variadic constructor of OverloadSet |
| 137 | // which can take a mix of l- and rvalues. |
| 138 | CopyOnly copyOnly; |
| 139 | const auto visitor = Callable::OverloadSet( |
| 140 | &X::member, |
| 141 | &Y::template memberfunction<Const>, |
| 142 | &Z::constmemberfunction, |
| 143 | nakedFunction, |
| 144 | moveOnly(), |
| 145 | copyOnly |
| 146 | ); |
| 147 | |
| 148 | X x; |
| 149 | Y y; |
| 150 | Z z; |
| 151 | float f{}; |
| 152 | double d{}; |
| 153 | long double ld{}; |
| 154 | |
| 155 | // Pointer to data member, captured as INVOKE-able, can only return lvalue |
| 156 | // references, so it is excluded from other test cases |
| 157 | if constexpr (ref == lvalue) |
| 158 | testCase(visitor, 0, x); |
| 159 | |
| 160 | testCase(visitor, 1, y); |
| 161 | testCase(visitor, 2, z); |
| 162 | testCase(visitor, 3, f); |
| 163 | testCase(visitor, 4, d); |
| 164 | testCase(visitor, 5, ld); |
| 165 | |
| 166 | // An invocable can distinguish its own value category and constness |
| 167 | REQUIRE(6 == std::move(visitor)(ld)); |
| 168 | using ConstVisitorType = decltype(visitor); |
| 169 | using VisitorType = std::remove_const_t<ConstVisitorType>; |
| 170 | auto &mutVisitor = const_cast<VisitorType&>(visitor); |
| 171 | REQUIRE(7 == mutVisitor(ld)); |
| 172 | REQUIRE(8 == std::move(mutVisitor)(ld)); |
| 173 | } |
| 174 | |
| 175 | }; // stateless struct Tester |
| 176 |
no test coverage detected