Use std::ref instead of copying the function parameter… (#290)

* GHA: revise numerous CI jobs. Fix sanitizer on new kernel

* Use std::ref instead of copying the function parameter in std::initializer_list overloads of insert_{or|and}_[c]visit

* Reimplement detail::is_invocable

* Update docs for std::ref(f) changes

---------

Co-authored-by: sdarwin <samuel.d.darwin@gmail.com>
This commit is contained in:
Braden Ganetsky
2024-10-08 17:35:58 +02:00
committed by GitHub
co-authored by sdarwin
parent 94ab2f0776
commit e214ecdbd0
11 changed files with 65 additions and 36 deletions
+16
View File
@@ -947,6 +947,14 @@ namespace {
}
} iterator_range_insert_and_visit;
struct non_copyable_function
{
non_copyable_function() = default;
non_copyable_function(const non_copyable_function&) = delete;
non_copyable_function(non_copyable_function&&) = default;
template <class... Args> void operator()(Args&&...) const {}
};
template <class X, class GF, class F>
void insert(X*, GF gen_factory, F inserter, test::random_generator rg)
{
@@ -1047,6 +1055,9 @@ namespace {
++num_invokes;
}),
init_list.size());
x.insert_or_visit(init_list, non_copyable_function{});
x.insert_or_cvisit(init_list, non_copyable_function{});
});
BOOST_TEST_EQ(num_invokes, (init_list.size() - x.size()) +
@@ -1105,6 +1116,11 @@ namespace {
++num_invokes;
}),
init_list.size());
x.insert_and_visit(
init_list, non_copyable_function{}, non_copyable_function{});
x.insert_and_cvisit(
init_list, non_copyable_function{}, non_copyable_function{});
});
BOOST_TEST_EQ(num_inserts, x.size());