mirror of
https://github.com/boostorg/compat.git
synced 2026-01-19 04:02:16 +00:00
Merge pull request #17 from cmazakas/fix/lvalue-params
fix lvalue parameter passing
This commit is contained in:
@@ -131,7 +131,7 @@ public:
|
||||
function_ref_base(const function_ref_base&) noexcept = default;
|
||||
function_ref_base& operator=(const function_ref_base&) noexcept = default;
|
||||
|
||||
R operator()(Args&&... args) const noexcept(NoEx) { return this->invoke_(thunk_, std::forward<Args>(args)...); }
|
||||
R operator()(Args... args) const noexcept(NoEx) { return this->invoke_(thunk_, std::forward<Args>(args)...); }
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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&>));
|
||||
|
||||
Reference in New Issue
Block a user