From 83c08b4497cf93faffb34f41263adf09d9305102 Mon Sep 17 00:00:00 2001 From: Marshall Clow Date: Mon, 29 Jul 2013 14:21:53 +0000 Subject: Implement N3421; comparison predicates llvm-svn: 187357 --- libcxx/include/functional | 326 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 311 insertions(+), 15 deletions(-) (limited to 'libcxx/include/functional') diff --git a/libcxx/include/functional b/libcxx/include/functional index d1a6301fb87..2130f0e36cd 100644 --- a/libcxx/include/functional +++ b/libcxx/include/functional @@ -68,96 +68,120 @@ template reference_wrapper cref(const T& t) noexcept; template void cref(const T&& t) = delete; template reference_wrapper cref(reference_wrapper t) noexcept; -template +template // in C++14 struct plus : binary_function { T operator()(const T& x, const T& y) const; }; -template +template // in C++14 struct minus : binary_function { T operator()(const T& x, const T& y) const; }; -template +template // in C++14 struct multiplies : binary_function { T operator()(const T& x, const T& y) const; }; -template +template // in C++14 struct divides : binary_function { T operator()(const T& x, const T& y) const; }; -template +template // in C++14 struct modulus : binary_function { T operator()(const T& x, const T& y) const; }; -template +template // in C++14 struct negate : unary_function { T operator()(const T& x) const; }; -template +template // in C++14 struct equal_to : binary_function { bool operator()(const T& x, const T& y) const; }; -template +template // in C++14 struct not_equal_to : binary_function { bool operator()(const T& x, const T& y) const; }; -template +template // in C++14 struct greater : binary_function { bool operator()(const T& x, const T& y) const; }; -template +template // in C++14 struct less : binary_function { bool operator()(const T& x, const T& y) const; }; -template +template // in C++14 struct greater_equal : binary_function { bool operator()(const T& x, const T& y) const; }; -template +template // in C++14 struct less_equal : binary_function { bool operator()(const T& x, const T& y) const; }; -template +template // in C++14 struct logical_and : binary_function { bool operator()(const T& x, const T& y) const; }; -template +template // in C++14 struct logical_or : binary_function { bool operator()(const T& x, const T& y) const; }; -template +template // in C++14 struct logical_not : unary_function { bool operator()(const T& x) const; }; +template // in C++14 +struct bit_and : unary_function +{ + bool operator()(const T& x, const T& y) const; +}; + +template // in C++14 +struct bit_or : unary_function +{ + bool operator()(const T& x, const T& y) const; +}; + +template // in C++14 +struct bit_xor : unary_function +{ + bool operator()(const T& x, const T& y) const; +}; + +template // C++14 +struct bit_xor : unary_function +{ + bool operator()(const T& x) const; +}; + template class unary_negate : public unary_function @@ -473,127 +497,399 @@ POLICY: For non-variadic implementations, the number of arguments is limited _LIBCPP_BEGIN_NAMESPACE_STD +#if _LIBCPP_STD_VER > 11 +template +#else template +#endif struct _LIBCPP_TYPE_VIS plus : binary_function<_Tp, _Tp, _Tp> { _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const {return __x + __y;} }; +#if _LIBCPP_STD_VER > 11 +template <> +struct _LIBCPP_TYPE_VIS plus +{ + template + _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const + { return _VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u); } +}; +#endif + + +#if _LIBCPP_STD_VER > 11 +template +#else template +#endif struct _LIBCPP_TYPE_VIS minus : binary_function<_Tp, _Tp, _Tp> { _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const {return __x - __y;} }; +#if _LIBCPP_STD_VER > 11 +template <> +struct _LIBCPP_TYPE_VIS minus +{ + template + _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const + { return _VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u); } +}; +#endif + + +#if _LIBCPP_STD_VER > 11 +template +#else template +#endif struct _LIBCPP_TYPE_VIS multiplies : binary_function<_Tp, _Tp, _Tp> { _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const {return __x * __y;} }; +#if _LIBCPP_STD_VER > 11 +template <> +struct _LIBCPP_TYPE_VIS multiplies +{ + template + _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const + { return _VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u); } +}; +#endif + + +#if _LIBCPP_STD_VER > 11 +template +#else template +#endif struct _LIBCPP_TYPE_VIS divides : binary_function<_Tp, _Tp, _Tp> { _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const {return __x / __y;} }; +#if _LIBCPP_STD_VER > 11 +template <> +struct _LIBCPP_TYPE_VIS divides +{ + template + _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const + { return _VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u); } +}; +#endif + + +#if _LIBCPP_STD_VER > 11 +template +#else template +#endif struct _LIBCPP_TYPE_VIS modulus : binary_function<_Tp, _Tp, _Tp> { _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const {return __x % __y;} }; +#if _LIBCPP_STD_VER > 11 +template <> +struct _LIBCPP_TYPE_VIS modulus +{ + template + _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const + { return _VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u); } +}; +#endif + + +#if _LIBCPP_STD_VER > 11 +template +#else template +#endif struct _LIBCPP_TYPE_VIS negate : unary_function<_Tp, _Tp> { _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x) const {return -__x;} }; +#if _LIBCPP_STD_VER > 11 +template <> +struct _LIBCPP_TYPE_VIS negate +{ + template + _LIBCPP_INLINE_VISIBILITY auto operator()(_Tp&& __x) const + { return -_VSTD::forward<_Tp>(__x); } +}; +#endif + + +#if _LIBCPP_STD_VER > 11 +template +#else template +#endif struct _LIBCPP_TYPE_VIS equal_to : binary_function<_Tp, _Tp, bool> { _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const {return __x == __y;} }; +#if _LIBCPP_STD_VER > 11 +template <> +struct _LIBCPP_TYPE_VIS equal_to +{ + template _LIBCPP_INLINE_VISIBILITY + auto operator()(_T1&& __t, _T2&& __u) const + { return _VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u); } +}; +#endif + + +#if _LIBCPP_STD_VER > 11 +template +#else template +#endif struct _LIBCPP_TYPE_VIS not_equal_to : binary_function<_Tp, _Tp, bool> { _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const {return __x != __y;} }; +#if _LIBCPP_STD_VER > 11 +template <> +struct _LIBCPP_TYPE_VIS not_equal_to +{ + template _LIBCPP_INLINE_VISIBILITY + auto operator()(_T1&& __t, _T2&& __u) const + { return _VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u); } +}; +#endif + + +#if _LIBCPP_STD_VER > 11 +template +#else template +#endif struct _LIBCPP_TYPE_VIS greater : binary_function<_Tp, _Tp, bool> { _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const {return __x > __y;} }; +#if _LIBCPP_STD_VER > 11 +template <> +struct _LIBCPP_TYPE_VIS greater +{ + template _LIBCPP_INLINE_VISIBILITY + auto operator()(_T1&& __t, _T2&& __u) const + { return _VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u); } +}; +#endif + + // less in <__functional_base> +#if _LIBCPP_STD_VER > 11 +template +#else template +#endif struct _LIBCPP_TYPE_VIS greater_equal : binary_function<_Tp, _Tp, bool> { _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const {return __x >= __y;} }; +#if _LIBCPP_STD_VER > 11 +template <> +struct _LIBCPP_TYPE_VIS greater_equal +{ + template _LIBCPP_INLINE_VISIBILITY + auto operator()(_T1&& __t, _T2&& __u) const + { return _VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u); } +}; +#endif + + +#if _LIBCPP_STD_VER > 11 +template +#else template +#endif struct _LIBCPP_TYPE_VIS less_equal : binary_function<_Tp, _Tp, bool> { _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const {return __x <= __y;} }; +#if _LIBCPP_STD_VER > 11 +template <> +struct _LIBCPP_TYPE_VIS less_equal +{ + template _LIBCPP_INLINE_VISIBILITY + auto operator()(_T1&& __t, _T2&& __u) const + { return _VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u); } +}; +#endif + + +#if _LIBCPP_STD_VER > 11 +template +#else template +#endif struct _LIBCPP_TYPE_VIS logical_and : binary_function<_Tp, _Tp, bool> { _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const {return __x && __y;} }; +#if _LIBCPP_STD_VER > 11 +template <> +struct _LIBCPP_TYPE_VIS logical_and +{ + template _LIBCPP_INLINE_VISIBILITY + auto operator()(_T1&& __t, _T2&& __u) const + { return _VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u); } +}; +#endif + + +#if _LIBCPP_STD_VER > 11 +template +#else template +#endif struct _LIBCPP_TYPE_VIS logical_or : binary_function<_Tp, _Tp, bool> { _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const {return __x || __y;} }; +#if _LIBCPP_STD_VER > 11 +template <> +struct _LIBCPP_TYPE_VIS logical_or +{ + template _LIBCPP_INLINE_VISIBILITY + auto operator()(_T1&& __t, _T2&& __u) const + { return _VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u); } +}; +#endif + + +#if _LIBCPP_STD_VER > 11 +template +#else template +#endif struct _LIBCPP_TYPE_VIS logical_not : unary_function<_Tp, bool> { _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x) const {return !__x;} }; +#if _LIBCPP_STD_VER > 11 +template <> +struct _LIBCPP_TYPE_VIS logical_not +{ + template + _LIBCPP_INLINE_VISIBILITY auto operator()(_Tp&& __x) const + { return !_VSTD::forward<_Tp>(__x); } +}; +#endif + + +#if _LIBCPP_STD_VER > 11 +template +#else template +#endif struct _LIBCPP_TYPE_VIS bit_and : binary_function<_Tp, _Tp, _Tp> { _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const {return __x & __y;} }; +#if _LIBCPP_STD_VER > 11 +template <> +struct _LIBCPP_TYPE_VIS bit_and +{ + template _LIBCPP_INLINE_VISIBILITY + auto operator()(_T1&& __t, _T2&& __u) const + { return _VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u); } +}; +#endif + + +#if _LIBCPP_STD_VER > 11 +template +#else template +#endif struct _LIBCPP_TYPE_VIS bit_or : binary_function<_Tp, _Tp, _Tp> { _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const {return __x | __y;} }; +#if _LIBCPP_STD_VER > 11 +template <> +struct _LIBCPP_TYPE_VIS bit_or +{ + template _LIBCPP_INLINE_VISIBILITY + auto operator()(_T1&& __t, _T2&& __u) const + { return _VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u); } +}; +#endif + + +#if _LIBCPP_STD_VER > 11 +template +#else template +#endif struct _LIBCPP_TYPE_VIS bit_xor : binary_function<_Tp, _Tp, _Tp> { _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const {return __x ^ __y;} }; +#if _LIBCPP_STD_VER > 11 +template <> +struct _LIBCPP_TYPE_VIS bit_xor +{ + template _LIBCPP_INLINE_VISIBILITY + auto operator()(_T1&& __t, _T2&& __u) const + { return _VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u); } +}; +#endif + + +#if _LIBCPP_STD_VER > 11 +template +struct _LIBCPP_TYPE_VIS bit_not : unary_function<_Tp, _Tp> +{ + _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x) const + {return ~__x;} +}; + +template <> +struct _LIBCPP_TYPE_VIS bit_not +{ + template + _LIBCPP_INLINE_VISIBILITY auto operator()(_Tp&& __x) const + { return ~_VSTD::forward<_Tp>(__x); } +}; +#endif + template class _LIBCPP_TYPE_VIS unary_negate : public unary_function -- cgit v1.2.3