2 //===----------------------------------------------------------------------===//
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8 //===----------------------------------------------------------------------===//
10 #ifndef _LIBCPP___FUNCTIONAL_NOT_FN_H
11 #define _LIBCPP___FUNCTIONAL_NOT_FN_H
14 #include <__functional/invoke.h>
15 #include <__functional/perfect_forward.h>
18 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19 #pragma GCC system_header
22 _LIBCPP_BEGIN_NAMESPACE_STD
24 #if _LIBCPP_STD_VER > 14
27 template <class... _Args>
29 _LIBCPP_CONSTEXPR_AFTER_CXX17 auto operator()(_Args&&... __args) const
30 noexcept(noexcept(!_VSTD::invoke(_VSTD::forward<_Args>(__args)...)))
31 -> decltype( !_VSTD::invoke(_VSTD::forward<_Args>(__args)...))
32 { return !_VSTD::invoke(_VSTD::forward<_Args>(__args)...); }
36 struct __not_fn_t : __perfect_forward<__not_fn_op, _Fn> {
37 using __perfect_forward<__not_fn_op, _Fn>::__perfect_forward;
40 template <class _Fn, class = enable_if_t<
41 is_constructible_v<decay_t<_Fn>, _Fn> &&
42 is_move_constructible_v<decay_t<_Fn>>
45 _LIBCPP_CONSTEXPR_AFTER_CXX17 auto not_fn(_Fn&& __f) {
46 return __not_fn_t<decay_t<_Fn>>(_VSTD::forward<_Fn>(__f));
49 #endif // _LIBCPP_STD_VER > 14
51 _LIBCPP_END_NAMESPACE_STD
53 #endif // _LIBCPP___FUNCTIONAL_NOT_FN_H