forked from boostorg/unordered
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:
co-authored by
sdarwin
parent
94ab2f0776
commit
e214ecdbd0
@@ -13,10 +13,7 @@
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/mp11/algorithm.hpp>
|
||||
#include <boost/mp11/list.hpp>
|
||||
|
||||
#include <functional>
|
||||
#include <iterator>
|
||||
#include <type_traits>
|
||||
#include <boost/unordered/detail/type_traits.hpp>
|
||||
|
||||
#define BOOST_UNORDERED_STATIC_ASSERT_INVOCABLE(F) \
|
||||
static_assert(boost::unordered::detail::is_invocable<F, value_type&>::value, \
|
||||
@@ -79,13 +76,20 @@
|
||||
namespace boost {
|
||||
namespace unordered {
|
||||
namespace detail {
|
||||
template <class F, class... Args>
|
||||
struct is_invocable
|
||||
: std::is_constructible<std::function<void(Args...)>,
|
||||
std::reference_wrapper<typename std::remove_reference<F>::type> >
|
||||
template <class...> struct is_invocable_helper : std::false_type
|
||||
{
|
||||
};
|
||||
|
||||
template <class F, class... Args>
|
||||
struct is_invocable_helper<
|
||||
void_t<decltype(std::declval<F>()(std::declval<Args>()...))>, F,
|
||||
Args...> : std::true_type
|
||||
{
|
||||
};
|
||||
|
||||
template <class F, class... Args>
|
||||
using is_invocable = is_invocable_helper<void, F, Args...>;
|
||||
|
||||
} // namespace detail
|
||||
|
||||
} // namespace unordered
|
||||
|
||||
Reference in New Issue
Block a user