};
// Partial specialization of the primary template for the case where the extra
- // arguments of the adaptor can always be safely forwarded by const reference.
- // This lets us get away with a single operator() overload, which makes
- // overload resolution failure diagnostics more concise.
+ // arguments of the adaptor can always be safely and efficiently forwarded by
+ // const reference. This lets us get away with a single operator() overload,
+ // which makes overload resolution failure diagnostics more concise.
template<typename _Adaptor, typename... _Args>
requires __adaptor_has_simple_extra_args<_Adaptor, _Args...>
+ && (is_trivially_copyable_v<_Args> && ...)
struct _Partial<_Adaptor, _Args...> : _RangeAdaptorClosure
{
tuple<_Args...> _M_args;
// where _Adaptor accepts a single extra argument.
template<typename _Adaptor, typename _Arg>
requires __adaptor_has_simple_extra_args<_Adaptor, _Arg>
+ && is_trivially_copyable_v<_Arg>
struct _Partial<_Adaptor, _Arg> : _RangeAdaptorClosure
{
_Arg _M_arg;
// PR libstdc++/100577
#include <ranges>
+#include <functional>
namespace ranges = std::ranges;
namespace views = std::ranges::views;
x | std::views::drop(S{});
}
+void
+test04()
+{
+ // Non-trivially-copyable extra arguments make a closure not simple.
+ using F = std::function<bool(bool)>;
+ static_assert(!std::is_trivially_copyable_v<F>);
+ using views::__adaptor::__closure_has_simple_call_op;
+ static_assert(!__closure_has_simple_call_op<decltype(views::take_while(std::declval<F>()))>);
+ static_assert(!__closure_has_simple_call_op<decltype(views::drop_while(std::declval<F>()))>);
+ static_assert(!__closure_has_simple_call_op<decltype(views::filter(std::declval<F>()))>);
+ static_assert(!__closure_has_simple_call_op<decltype(views::transform(std::declval<F>()))>);
+}
+
// { dg-prune-output "in requirements" }