/// \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 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 explicit constexpr CPP_ctor(logical_negate)(T && pred)( // requires(!defer::same_as, logical_negate>) && defer::constructible_from) : pred_(static_cast(pred)) {} template constexpr auto operator()(Args &&... args) & -> CPP_ret(bool)( // requires predicate) { return !invoke(pred_, static_cast(args)...); } /// \overload template constexpr auto operator()(Args &&... args) const & -> CPP_ret(bool)( // requires predicate) { return !invoke(pred_, static_cast(args)...); } /// \overload template constexpr auto operator()(Args &&... args) && -> CPP_ret(bool)( // requires predicate) { return !invoke(static_cast(pred_), static_cast(args)...); } }; struct not_fn_fn { template constexpr auto operator()(Pred && pred) const -> CPP_ret(logical_negate>)( // requires move_constructible> && constructible_from, Pred>) { 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 #endif