xref: /freebsd/contrib/llvm-project/libcxx/include/__cxx03/__functional/binary_negate.h (revision 700637cbb5e582861067a11aaca4d053546871d2)
1 // -*- C++ -*-
2 //===----------------------------------------------------------------------===//
3 //
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
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #ifndef _LIBCPP___CXX03___FUNCTIONAL_BINARY_NEGATE_H
11 #define _LIBCPP___CXX03___FUNCTIONAL_BINARY_NEGATE_H
12 
13 #include <__cxx03/__config>
14 #include <__cxx03/__functional/binary_function.h>
15 
16 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17 #  pragma GCC system_header
18 #endif
19 
20 _LIBCPP_BEGIN_NAMESPACE_STD
21 
22 template <class _Predicate>
23 class _LIBCPP_TEMPLATE_VIS binary_negate
24     : public __binary_function<typename _Predicate::first_argument_type,
25                                typename _Predicate::second_argument_type,
26                                bool> {
27   _Predicate __pred_;
28 
29 public:
binary_negate(const _Predicate & __pred)30   _LIBCPP_HIDE_FROM_ABI explicit binary_negate(const _Predicate& __pred) : __pred_(__pred) {}
31 
operator()32   _LIBCPP_HIDE_FROM_ABI bool operator()(const typename _Predicate::first_argument_type& __x,
33                                         const typename _Predicate::second_argument_type& __y) const {
34     return !__pred_(__x, __y);
35   }
36 };
37 
38 template <class _Predicate>
not2(const _Predicate & __pred)39 inline _LIBCPP_HIDE_FROM_ABI binary_negate<_Predicate> not2(const _Predicate& __pred) {
40   return binary_negate<_Predicate>(__pred);
41 }
42 
43 _LIBCPP_END_NAMESPACE_STD
44 
45 #endif // _LIBCPP___CXX03___FUNCTIONAL_BINARY_NEGATE_H
46