/// \file // Range v3 library // // Copyright Eric Niebler 2013-present // // Use, modification and distribution is subject to the // Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // // Project home: https://github.com/ericniebler/range-v3 // #ifndef RANGES_V3_FUNCTIONAL_NOT_FN_HPP #define RANGES_V3_FUNCTIONAL_NOT_FN_HPP #include #include #include #include #include #include #include namespace ranges { /// \addtogroup group-functional /// @{ template struct logical_negate { private: CPP_assert(same_as> && move_constructible); RANGES_NO_UNIQUE_ADDRESS FD pred_; public: CPP_member constexpr CPP_ctor(logical_negate)()( // noexcept(std::is_nothrow_default_constructible::value) // requires default_constructible) {} template(typename T)( requires (!same_as, logical_negate>) AND constructible_from) constexpr explicit logical_negate(T && pred) : pred_(static_cast(pred)) {} template(typename... Args)( requires predicate) constexpr bool operator()(Args &&... args) & { return !invoke(pred_, static_cast(args)...); } /// \overload template(typename... Args)( requires predicate) constexpr bool operator()(Args &&... args) const & { return !invoke(pred_, static_cast(args)...); } /// \overload template(typename... Args)( requires predicate) constexpr bool operator()(Args &&... args) && { return !invoke(static_cast(pred_), static_cast(args)...); } }; struct not_fn_fn { template(typename Pred)( requires move_constructible> AND constructible_from, Pred>) constexpr logical_negate> operator()(Pred && pred) const { return logical_negate>{(Pred &&) pred}; } }; /// \ingroup group-functional /// \sa `not_fn_fn` RANGES_INLINE_VARIABLE(not_fn_fn, not_fn) namespace cpp20 { using ranges::not_fn; } /// @} } // namespace ranges #include #endif