Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-03 08:13:31

0001 // -*- C++ -*-
0002 //===----------------------------------------------------------------------===//
0003 //
0004 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0005 // See https://llvm.org/LICENSE.txt for license information.
0006 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0007 //
0008 //===----------------------------------------------------------------------===//
0009 
0010 #ifndef _LIBCPP___CXX03___FUNCTIONAL_NOT_FN_H
0011 #define _LIBCPP___CXX03___FUNCTIONAL_NOT_FN_H
0012 
0013 #include <__cxx03/__config>
0014 #include <__cxx03/__functional/invoke.h>
0015 #include <__cxx03/__functional/perfect_forward.h>
0016 #include <__cxx03/__type_traits/decay.h>
0017 #include <__cxx03/__type_traits/enable_if.h>
0018 #include <__cxx03/__type_traits/is_constructible.h>
0019 #include <__cxx03/__utility/forward.h>
0020 
0021 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0022 #  pragma GCC system_header
0023 #endif
0024 
0025 _LIBCPP_BEGIN_NAMESPACE_STD
0026 
0027 #if _LIBCPP_STD_VER >= 17
0028 
0029 struct __not_fn_op {
0030   template <class... _Args>
0031   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 auto operator()(_Args&&... __args) const
0032       noexcept(noexcept(!std::invoke(std::forward<_Args>(__args)...)))
0033           -> decltype(!std::invoke(std::forward<_Args>(__args)...)) {
0034     return !std::invoke(std::forward<_Args>(__args)...);
0035   }
0036 };
0037 
0038 template <class _Fn>
0039 struct __not_fn_t : __perfect_forward<__not_fn_op, _Fn> {
0040   using __perfect_forward<__not_fn_op, _Fn>::__perfect_forward;
0041 };
0042 
0043 template <class _Fn,
0044           class = enable_if_t< is_constructible_v<decay_t<_Fn>, _Fn> && is_move_constructible_v<decay_t<_Fn>> >>
0045 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 auto not_fn(_Fn&& __f) {
0046   return __not_fn_t<decay_t<_Fn>>(std::forward<_Fn>(__f));
0047 }
0048 
0049 #endif // _LIBCPP_STD_VER >= 17
0050 
0051 _LIBCPP_END_NAMESPACE_STD
0052 
0053 #endif // _LIBCPP___CXX03___FUNCTIONAL_NOT_FN_H