Path: blob/main/contrib/llvm-project/libcxx/include/__functional/not_fn.h
35260 views
// -*- C++ -*-1//===----------------------------------------------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//89#ifndef _LIBCPP___FUNCTIONAL_NOT_FN_H10#define _LIBCPP___FUNCTIONAL_NOT_FN_H1112#include <__config>13#include <__functional/invoke.h>14#include <__functional/perfect_forward.h>15#include <__type_traits/decay.h>16#include <__type_traits/enable_if.h>17#include <__type_traits/is_constructible.h>18#include <__utility/forward.h>1920#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)21# pragma GCC system_header22#endif2324_LIBCPP_BEGIN_NAMESPACE_STD2526#if _LIBCPP_STD_VER >= 172728struct __not_fn_op {29template <class... _Args>30_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 auto operator()(_Args&&... __args) const31noexcept(noexcept(!std::invoke(std::forward<_Args>(__args)...)))32-> decltype(!std::invoke(std::forward<_Args>(__args)...)) {33return !std::invoke(std::forward<_Args>(__args)...);34}35};3637template <class _Fn>38struct __not_fn_t : __perfect_forward<__not_fn_op, _Fn> {39using __perfect_forward<__not_fn_op, _Fn>::__perfect_forward;40};4142template <class _Fn,43class = enable_if_t< is_constructible_v<decay_t<_Fn>, _Fn> && is_move_constructible_v<decay_t<_Fn>> >>44_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 auto not_fn(_Fn&& __f) {45return __not_fn_t<decay_t<_Fn>>(std::forward<_Fn>(__f));46}4748#endif // _LIBCPP_STD_VER >= 174950_LIBCPP_END_NAMESPACE_STD5152#endif // _LIBCPP___FUNCTIONAL_NOT_FN_H535455