|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
-
-
-
-
-
-
-
-
-
-
-
-
- #ifndef RANGES_V3_FUNCTIONAL_NOT_FN_HPP
- #define RANGES_V3_FUNCTIONAL_NOT_FN_HPP
-
- #include <type_traits>
-
- #include <concepts/concepts.hpp>
-
- #include <range/v3/range_fwd.hpp>
-
- #include <range/v3/functional/concepts.hpp>
- #include <range/v3/functional/invoke.hpp>
- #include <range/v3/utility/static_const.hpp>
-
- namespace ranges
- {
-
-
- template<typename FD>
- struct logical_negate
- {
- private:
- CPP_assert(same_as<FD, detail::decay_t<FD>> && move_constructible<FD>);
- RANGES_NO_UNIQUE_ADDRESS FD pred_;
-
- public:
- CPP_member
- constexpr CPP_ctor(logical_negate)()(
- noexcept(std::is_nothrow_default_constructible<FD>::value)
- requires default_constructible<FD>)
- {}
- template<typename T>
- explicit constexpr CPP_ctor(logical_negate)(T && pred)(
- requires(!defer::same_as<detail::decay_t<T>, logical_negate>) &&
- defer::constructible_from<FD, T>)
- : pred_(static_cast<T &&>(pred))
- {}
-
- template<typename... Args>
- constexpr auto operator()(Args &&... args) & -> CPP_ret(bool)(
- requires predicate<FD &, Args...>)
- {
- return !invoke(pred_, static_cast<Args &&>(args)...);
- }
-
- template<typename... Args>
- constexpr auto operator()(Args &&... args) const & -> CPP_ret(bool)(
- requires predicate<FD const &, Args...>)
- {
- return !invoke(pred_, static_cast<Args &&>(args)...);
- }
-
- template<typename... Args>
- constexpr auto operator()(Args &&... args) && -> CPP_ret(bool)(
- requires predicate<FD, Args...>)
- {
- return !invoke(static_cast<FD &&>(pred_), static_cast<Args &&>(args)...);
- }
- };
-
- struct not_fn_fn
- {
- template<typename Pred>
- constexpr auto operator()(Pred && pred) const
- -> CPP_ret(logical_negate<detail::decay_t<Pred>>)(
- requires move_constructible<detail::decay_t<Pred>> &&
- constructible_from<detail::decay_t<Pred>, Pred>)
- {
- return logical_negate<detail::decay_t<Pred>>{(Pred &&) pred};
- }
- };
-
-
-
- RANGES_INLINE_VARIABLE(not_fn_fn, not_fn)
-
- namespace cpp20
- {
- using ranges::not_fn;
- }
-
- }
-
- #endif
|