Skip to content

Commit 6a11cd5

Browse files
committed
Improve perfect forwarding test a little bit
Comment: #165096 (comment) >the test looks nice. but it would be even better if we can let the test to run the function instead of just check the type
1 parent fd81525 commit 6a11cd5

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

libcxx/test/std/utilities/function.objects/func.bind.partial/bind_front.nttp.pass.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -271,17 +271,17 @@ constexpr void test_perfect_forwarding_call_wrapper() {
271271

272272
{ // Test perfect forwarding when various overloads are available
273273
struct X {
274-
Tag<0> operator()(int&, char) const;
275-
Tag<1> operator()(const int&, char) const;
276-
Tag<2> operator()(int&&, char) const;
277-
Tag<3> operator()(const int&&, char) const;
274+
constexpr Tag<0> operator()(int&, char) const { return {}; }
275+
constexpr Tag<1> operator()(const int&, char) const { return {}; }
276+
constexpr Tag<2> operator()(int&&, char) const { return {}; }
277+
constexpr Tag<3> operator()(const int&&, char) const { return {}; }
278278
};
279279

280-
using F = decltype(std::bind_front<X{}>(0));
281-
static_assert(std::same_as<std::invoke_result_t<F&, char>, Tag<0>>);
282-
static_assert(std::same_as<std::invoke_result_t<const F&, char>, Tag<1>>);
283-
static_assert(std::same_as<std::invoke_result_t<F, char>, Tag<2>>);
284-
static_assert(std::same_as<std::invoke_result_t<const F, char>, Tag<3>>);
280+
auto f = std::bind_front<X{}>(0);
281+
std::same_as<Tag<0>> auto _ = f('a');
282+
std::same_as<Tag<1>> auto _ = std::as_const(f)('a');
283+
std::same_as<Tag<2>> auto _ = std::move(f)('a');
284+
std::same_as<Tag<3>> auto _ = std::move(std::as_const(f))('a');
285285
}
286286

287287
{ // Test perfect forwarding

0 commit comments

Comments
 (0)