2
0
mirror of https://github.com/boostorg/compat.git synced 2026-01-19 04:02:16 +00:00

add failing test case

Passing an lvalue ref parameter when arguments are by-value causes a failure of reference binding.
This commit is contained in:
Christian Mazakas
2024-12-17 10:55:34 -08:00
parent 881cc909fb
commit 736b381d13
3 changed files with 6 additions and 4 deletions

View File

@@ -98,8 +98,9 @@ int main() {
// f1
{
int x = 1;
compat::function_ref<int(int)> fv1(f1);
BOOST_TEST_EQ(fv1(1), 1);
BOOST_TEST_EQ(fv1(x), 1);
compat::function_ref<int(int) const> fv2(f1);
BOOST_TEST_EQ(fv2(1), 1);

View File

@@ -41,8 +41,9 @@ int main() {
compat::function_ref<int(F1&)> fn1(compat::nontype_t<&F1::m1>{});
BOOST_TEST_EQ(fn1(f1), 0);
int x = 2;
compat::function_ref<int(F1&, int)> fn2(compat::nontype_t<&F1::m2>{});
BOOST_TEST_EQ(fn2(f1, 2), 12);
BOOST_TEST_EQ(fn2(f1, x), 12);
compat::function_ref<int(F1&, int, int)> fn3(compat::nontype_t<&F1::m3>{});
BOOST_TEST_EQ(fn3(f1, 2, 3), 123);

View File

@@ -65,8 +65,8 @@ int main() {
BOOST_TEST_TRAIT_FALSE((std::is_constructible<compat::function_ref<S1>, F1 const&&>));
compat::function_ref<S2> fv2(f);
BOOST_TEST_EQ(fv2(1), 1);
int x = 1;
BOOST_TEST_EQ(fv2(x), 1);
BOOST_TEST_TRAIT_FALSE((std::is_constructible<compat::function_ref<S2>, F1 const>));
BOOST_TEST_TRAIT_FALSE((std::is_constructible<compat::function_ref<S2>, F1 const&>));