mirror of
https://github.com/boostorg/stl_interfaces.git
synced 2026-01-19 04:42:12 +00:00
Add an rvalue-qualified overload of closure::operator(). This makes
forwarding work properly in cases such as r | foo(std::string("foo")), where
foo is an adaptor. Without this, the std::string temporary dangles.
This commit is contained in:
@@ -242,11 +242,24 @@ namespace boost { namespace stl_interfaces {
|
||||
typename Enable =
|
||||
std::enable_if_t<detail::is_invocable_v<F const &, T>>>
|
||||
#endif
|
||||
constexpr decltype(auto) operator()(T && t) const
|
||||
constexpr decltype(auto) operator()(T && t) const &
|
||||
{
|
||||
return f_((T &&) t);
|
||||
}
|
||||
|
||||
#if BOOST_STL_INTERFACES_USE_CONCEPTS
|
||||
template<typename T>
|
||||
requires std::invocable<F &&, T>
|
||||
#else
|
||||
template<
|
||||
typename T,
|
||||
typename Enable = std::enable_if_t<detail::is_invocable_v<F &&, T>>>
|
||||
#endif
|
||||
constexpr decltype(auto) operator()(T && t) &&
|
||||
{
|
||||
return std::move(f_)((T &&) t);
|
||||
}
|
||||
|
||||
private:
|
||||
F f_;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user