[libcxx] r187357 - Implement N3421; comparison predicates<void>

Marshall Clow mclow.lists at gmail.com
Mon Jul 29 07:21:54 PDT 2013


Author: marshall
Date: Mon Jul 29 09:21:53 2013
New Revision: 187357

URL: http://llvm.org/viewvc/llvm-project?rev=187357&view=rev
Log:
Implement N3421; comparison predicates<void>

Added:
    libcxx/trunk/test/utilities/function.objects/bitwise.operations/bit_not.pass.cpp
Modified:
    libcxx/trunk/include/__functional_base
    libcxx/trunk/include/functional
    libcxx/trunk/test/utilities/function.objects/arithmetic.operations/divides.pass.cpp
    libcxx/trunk/test/utilities/function.objects/arithmetic.operations/minus.pass.cpp
    libcxx/trunk/test/utilities/function.objects/arithmetic.operations/modulus.pass.cpp
    libcxx/trunk/test/utilities/function.objects/arithmetic.operations/multiplies.pass.cpp
    libcxx/trunk/test/utilities/function.objects/arithmetic.operations/negate.pass.cpp
    libcxx/trunk/test/utilities/function.objects/arithmetic.operations/plus.pass.cpp
    libcxx/trunk/test/utilities/function.objects/bitwise.operations/bit_and.pass.cpp
    libcxx/trunk/test/utilities/function.objects/bitwise.operations/bit_or.pass.cpp
    libcxx/trunk/test/utilities/function.objects/bitwise.operations/bit_xor.pass.cpp
    libcxx/trunk/test/utilities/function.objects/comparisons/equal_to.pass.cpp
    libcxx/trunk/test/utilities/function.objects/comparisons/greater.pass.cpp
    libcxx/trunk/test/utilities/function.objects/comparisons/greater_equal.pass.cpp
    libcxx/trunk/test/utilities/function.objects/comparisons/less.pass.cpp
    libcxx/trunk/test/utilities/function.objects/comparisons/less_equal.pass.cpp
    libcxx/trunk/test/utilities/function.objects/comparisons/not_equal_to.pass.cpp
    libcxx/trunk/test/utilities/function.objects/logical.operations/logical_and.pass.cpp
    libcxx/trunk/test/utilities/function.objects/logical.operations/logical_not.pass.cpp
    libcxx/trunk/test/utilities/function.objects/logical.operations/logical_or.pass.cpp

Modified: libcxx/trunk/include/__functional_base
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__functional_base?rev=187357&r1=187356&r2=187357&view=diff
==============================================================================
--- libcxx/trunk/include/__functional_base (original)
+++ libcxx/trunk/include/__functional_base Mon Jul 29 09:21:53 2013
@@ -50,13 +50,27 @@ public:
     static const bool value = sizeof(__test<_Tp>(0)) == 1;
 };
 
+#if _LIBCPP_STD_VER > 11
+template <class _Tp = void>
+#else
 template <class _Tp>
+#endif
 struct _LIBCPP_TYPE_VIS less : 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<void>
+{
+    template <class _T1, class _T2> _LIBCPP_INLINE_VISIBILITY
+    auto operator()(_T1&& __t, _T2&& __u) const
+        { return _VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u); }
+};
+#endif
+
 #ifdef _LIBCPP_HAS_NO_VARIADICS
 
 #include <__functional_base_03>

Modified: libcxx/trunk/include/functional
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/functional?rev=187357&r1=187356&r2=187357&view=diff
==============================================================================
--- libcxx/trunk/include/functional (original)
+++ libcxx/trunk/include/functional Mon Jul 29 09:21:53 2013
@@ -68,96 +68,120 @@ template <class T> reference_wrapper<con
 template <class T> void cref(const T&& t) = delete;
 template <class T> reference_wrapper<const T> cref(reference_wrapper<T> t) noexcept;
 
-template <class T>
+template <class T> // <class T=void> in C++14
 struct plus : binary_function<T, T, T>
 {
     T operator()(const T& x, const T& y) const;
 };
 
-template <class T>
+template <class T> // <class T=void> in C++14
 struct minus : binary_function<T, T, T>
 {
     T operator()(const T& x, const T& y) const;
 };
 
-template <class T>
+template <class T> // <class T=void> in C++14
 struct multiplies : binary_function<T, T, T>
 {
     T operator()(const T& x, const T& y) const;
 };
 
-template <class T>
+template <class T> // <class T=void> in C++14
 struct divides : binary_function<T, T, T>
 {
     T operator()(const T& x, const T& y) const;
 };
 
-template <class T>
+template <class T> // <class T=void> in C++14
 struct modulus : binary_function<T, T, T>
 {
     T operator()(const T& x, const T& y) const;
 };
 
-template <class T>
+template <class T> // <class T=void> in C++14
 struct negate : unary_function<T, T>
 {
     T operator()(const T& x) const;
 };
 
-template <class T>
+template <class T> // <class T=void> in C++14
 struct equal_to : binary_function<T, T, bool>
 {
     bool operator()(const T& x, const T& y) const;
 };
 
-template <class T>
+template <class T> // <class T=void> in C++14
 struct not_equal_to : binary_function<T, T, bool>
 {
     bool operator()(const T& x, const T& y) const;
 };
 
-template <class T>
+template <class T> // <class T=void> in C++14
 struct greater : binary_function<T, T, bool>
 {
     bool operator()(const T& x, const T& y) const;
 };
 
-template <class T>
+template <class T> // <class T=void> in C++14
 struct less : binary_function<T, T, bool>
 {
     bool operator()(const T& x, const T& y) const;
 };
 
-template <class T>
+template <class T> // <class T=void> in C++14
 struct greater_equal : binary_function<T, T, bool>
 {
     bool operator()(const T& x, const T& y) const;
 };
 
-template <class T>
+template <class T> // <class T=void> in C++14
 struct less_equal : binary_function<T, T, bool>
 {
     bool operator()(const T& x, const T& y) const;
 };
 
-template <class T>
+template <class T> // <class T=void> in C++14
 struct logical_and : binary_function<T, T, bool>
 {
     bool operator()(const T& x, const T& y) const;
 };
 
-template <class T>
+template <class T> // <class T=void> in C++14
 struct logical_or : binary_function<T, T, bool>
 {
     bool operator()(const T& x, const T& y) const;
 };
 
-template <class T>
+template <class T> // <class T=void> in C++14
 struct logical_not : unary_function<T, bool>
 {
     bool operator()(const T& x) const;
 };
 
+template <class T> // <class T=void> in C++14
+struct bit_and : unary_function<T, bool>
+{
+    bool operator()(const T& x, const T& y) const;
+};
+
+template <class T> // <class T=void> in C++14
+struct bit_or : unary_function<T, bool>
+{
+    bool operator()(const T& x, const T& y) const;
+};
+
+template <class T> // <class T=void> in C++14
+struct bit_xor : unary_function<T, bool>
+{
+    bool operator()(const T& x, const T& y) const;
+};
+
+template <class T=void> // C++14
+struct bit_xor : unary_function<T, bool>
+{
+    bool operator()(const T& x) const;
+};
+
 template <class Predicate>
 class unary_negate
     : public unary_function<typename Predicate::argument_type, bool>
@@ -473,127 +497,399 @@ POLICY:  For non-variadic implementation
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
+#if _LIBCPP_STD_VER > 11
+template <class _Tp = void>
+#else
 template <class _Tp>
+#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<void>
+{
+    template <class _T1, class _T2>
+    _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 <class _Tp = void>
+#else
 template <class _Tp>
+#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<void>
+{
+    template <class _T1, class _T2>
+    _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 <class _Tp = void>
+#else
 template <class _Tp>
+#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<void>
+{
+    template <class _T1, class _T2>
+    _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 <class _Tp = void>
+#else
 template <class _Tp>
+#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<void>
+{
+    template <class _T1, class _T2>
+    _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 <class _Tp = void>
+#else
 template <class _Tp>
+#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<void>
+{
+    template <class _T1, class _T2>
+    _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 <class _Tp = void>
+#else
 template <class _Tp>
+#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<void>
+{
+    template <class _Tp>
+    _LIBCPP_INLINE_VISIBILITY auto operator()(_Tp&& __x) const
+        { return -_VSTD::forward<_Tp>(__x); }
+};
+#endif
+
+
+#if _LIBCPP_STD_VER > 11
+template <class _Tp = void>
+#else
 template <class _Tp>
+#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<void>
+{
+    template <class _T1, class _T2> _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 <class _Tp = void>
+#else
 template <class _Tp>
+#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<void>
+{
+    template <class _T1, class _T2> _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 <class _Tp = void>
+#else
 template <class _Tp>
+#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<void>
+{
+    template <class _T1, class _T2> _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 <class _Tp = void>
+#else
 template <class _Tp>
+#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<void>
+{
+    template <class _T1, class _T2> _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 <class _Tp = void>
+#else
 template <class _Tp>
+#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<void>
+{
+    template <class _T1, class _T2> _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 <class _Tp = void>
+#else
 template <class _Tp>
+#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<void>
+{
+    template <class _T1, class _T2> _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 <class _Tp = void>
+#else
 template <class _Tp>
+#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<void>
+{
+    template <class _T1, class _T2> _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 <class _Tp = void>
+#else
 template <class _Tp>
+#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<void>
+{
+    template <class _Tp>
+    _LIBCPP_INLINE_VISIBILITY auto operator()(_Tp&& __x) const
+        { return !_VSTD::forward<_Tp>(__x); }
+};
+#endif
+
+
+#if _LIBCPP_STD_VER > 11
+template <class _Tp = void>
+#else
 template <class _Tp>
+#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<void>
+{
+    template <class _T1, class _T2> _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 <class _Tp = void>
+#else
 template <class _Tp>
+#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<void>
+{
+    template <class _T1, class _T2> _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 <class _Tp = void>
+#else
 template <class _Tp>
+#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<void>
+{
+    template <class _T1, class _T2> _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 <class _Tp = void>
+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<void>
+{
+    template <class _Tp>
+    _LIBCPP_INLINE_VISIBILITY auto operator()(_Tp&& __x) const
+        { return ~_VSTD::forward<_Tp>(__x); }
+};
+#endif
+
 template <class _Predicate>
 class _LIBCPP_TYPE_VIS unary_negate
     : public unary_function<typename _Predicate::argument_type, bool>

Modified: libcxx/trunk/test/utilities/function.objects/arithmetic.operations/divides.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/function.objects/arithmetic.operations/divides.pass.cpp?rev=187357&r1=187356&r2=187357&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/function.objects/arithmetic.operations/divides.pass.cpp (original)
+++ libcxx/trunk/test/utilities/function.objects/arithmetic.operations/divides.pass.cpp Mon Jul 29 09:21:53 2013
@@ -21,4 +21,11 @@ int main()
     const F f = F();
     static_assert((std::is_base_of<std::binary_function<int, int, int>, F>::value), "");
     assert(f(36, 4) == 9);
+#if _LIBCPP_STD_VER > 11
+    typedef std::divides<> F2;
+    const F2 f2 = F2();
+    assert(f2(36, 4) == 9);
+    assert(f2(36.0, 4) == 9);
+    assert(f2(18, 4.0) == 4.5); // exact in binary
+#endif
 }

Modified: libcxx/trunk/test/utilities/function.objects/arithmetic.operations/minus.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/function.objects/arithmetic.operations/minus.pass.cpp?rev=187357&r1=187356&r2=187357&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/function.objects/arithmetic.operations/minus.pass.cpp (original)
+++ libcxx/trunk/test/utilities/function.objects/arithmetic.operations/minus.pass.cpp Mon Jul 29 09:21:53 2013
@@ -21,4 +21,11 @@ int main()
     const F f = F();
     static_assert((std::is_base_of<std::binary_function<int, int, int>, F>::value), "");
     assert(f(3, 2) == 1);
+#if _LIBCPP_STD_VER > 11
+    typedef std::minus<> F2;
+    const F2 f2 = F2();
+    assert(f2(3,2) == 1);
+    assert(f2(3.0, 2) == 1);
+    assert(f2(3, 2.5) == 0.5);
+#endif
 }

Modified: libcxx/trunk/test/utilities/function.objects/arithmetic.operations/modulus.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/function.objects/arithmetic.operations/modulus.pass.cpp?rev=187357&r1=187356&r2=187357&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/function.objects/arithmetic.operations/modulus.pass.cpp (original)
+++ libcxx/trunk/test/utilities/function.objects/arithmetic.operations/modulus.pass.cpp Mon Jul 29 09:21:53 2013
@@ -21,4 +21,11 @@ int main()
     const F f = F();
     static_assert((std::is_base_of<std::binary_function<int, int, int>, F>::value), "");
     assert(f(36, 8) == 4);
+#if _LIBCPP_STD_VER > 11
+    typedef std::modulus<> F2;
+    const F2 f2 = F2();
+    assert(f2(36, 8) == 4);
+    assert(f2(36L, 8) == 4);
+    assert(f2(36, 8L) == 4);
+#endif
 }

Modified: libcxx/trunk/test/utilities/function.objects/arithmetic.operations/multiplies.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/function.objects/arithmetic.operations/multiplies.pass.cpp?rev=187357&r1=187356&r2=187357&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/function.objects/arithmetic.operations/multiplies.pass.cpp (original)
+++ libcxx/trunk/test/utilities/function.objects/arithmetic.operations/multiplies.pass.cpp Mon Jul 29 09:21:53 2013
@@ -21,4 +21,11 @@ int main()
     const F f = F();
     static_assert((std::is_base_of<std::binary_function<int, int, int>, F>::value), "");
     assert(f(3, 2) == 6);
+#if _LIBCPP_STD_VER > 11
+    typedef std::multiplies<> F2;
+    const F2 f2 = F2();
+    assert(f2(3,2) == 6);
+    assert(f2(3.0, 2) == 6);
+    assert(f2(3, 2.5) == 7.5); // exact in binary
+#endif
 }

Modified: libcxx/trunk/test/utilities/function.objects/arithmetic.operations/negate.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/function.objects/arithmetic.operations/negate.pass.cpp?rev=187357&r1=187356&r2=187357&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/function.objects/arithmetic.operations/negate.pass.cpp (original)
+++ libcxx/trunk/test/utilities/function.objects/arithmetic.operations/negate.pass.cpp Mon Jul 29 09:21:53 2013
@@ -21,4 +21,11 @@ int main()
     const F f = F();
     static_assert((std::is_base_of<std::unary_function<int, int>, F>::value), "");
     assert(f(36) == -36);
+#if _LIBCPP_STD_VER > 11
+    typedef std::negate<> F2;
+    const F2 f2 = F2();
+    assert(f2(36) == -36);
+    assert(f2(36L) == -36);
+    assert(f2(36.0) == -36);
+#endif
 }

Modified: libcxx/trunk/test/utilities/function.objects/arithmetic.operations/plus.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/function.objects/arithmetic.operations/plus.pass.cpp?rev=187357&r1=187356&r2=187357&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/function.objects/arithmetic.operations/plus.pass.cpp (original)
+++ libcxx/trunk/test/utilities/function.objects/arithmetic.operations/plus.pass.cpp Mon Jul 29 09:21:53 2013
@@ -21,4 +21,11 @@ int main()
     const F f = F();
     static_assert((std::is_base_of<std::binary_function<int, int, int>, F>::value), "");
     assert(f(3, 2) == 5);
+#if _LIBCPP_STD_VER > 11
+    typedef std::plus<> F2;
+    const F2 f2 = F2();
+    assert(f2(3,2) == 5);
+    assert(f2(3.0, 2) == 5);
+    assert(f2(3, 2.5) == 5.5);
+#endif
 }

Modified: libcxx/trunk/test/utilities/function.objects/bitwise.operations/bit_and.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/function.objects/bitwise.operations/bit_and.pass.cpp?rev=187357&r1=187356&r2=187357&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/function.objects/bitwise.operations/bit_and.pass.cpp (original)
+++ libcxx/trunk/test/utilities/function.objects/bitwise.operations/bit_and.pass.cpp Mon Jul 29 09:21:53 2013
@@ -25,4 +25,27 @@ int main()
     assert(f(0x58D3, 0xEA95) == 0x4891);
     assert(f(0x58D3, 0) == 0);
     assert(f(0xFFFF, 0x58D3) == 0x58D3);
+#if _LIBCPP_STD_VER > 11
+    typedef std::bit_and<> F2;
+    const F2 f2 = F2();
+    assert(f2(0xEA95, 0xEA95) == 0xEA95);
+    assert(f2(0xEA95L, 0xEA95) == 0xEA95);
+    assert(f2(0xEA95, 0xEA95L) == 0xEA95);
+
+    assert(f2(0xEA95, 0x58D3) == 0x4891);
+    assert(f2(0xEA95L, 0x58D3) == 0x4891);
+    assert(f2(0xEA95, 0x58D3L) == 0x4891);
+
+    assert(f2(0x58D3, 0xEA95) == 0x4891);
+    assert(f2(0x58D3L, 0xEA95) == 0x4891);
+    assert(f2(0x58D3, 0xEA95L) == 0x4891);
+
+    assert(f2(0x58D3, 0) == 0);
+    assert(f2(0x58D3L, 0) == 0);
+    assert(f2(0x58D3, 0L) == 0);
+
+    assert(f2(0xFFFF, 0x58D3) == 0x58D3);
+    assert(f2(0xFFFFL, 0x58D3) == 0x58D3);
+    assert(f2(0xFFFF, 0x58D3L) == 0x58D3);
+#endif
 }

Added: libcxx/trunk/test/utilities/function.objects/bitwise.operations/bit_not.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/function.objects/bitwise.operations/bit_not.pass.cpp?rev=187357&view=auto
==============================================================================
--- libcxx/trunk/test/utilities/function.objects/bitwise.operations/bit_not.pass.cpp (added)
+++ libcxx/trunk/test/utilities/function.objects/bitwise.operations/bit_not.pass.cpp Mon Jul 29 09:21:53 2013
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// bit_not
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    typedef std::bit_not<int> F;
+    const F f = F();
+    static_assert((std::is_base_of<std::unary_function<int, int>, F>::value), "");
+    assert((f(0xEA95) & 0xFFFF ) == 0x156A);
+    assert((f(0x58D3) & 0xFFFF ) == 0xA72C);
+    assert((f(0)      & 0xFFFF ) == 0xFFFF);
+    assert((f(0xFFFF) & 0xFFFF ) == 0);
+
+    typedef std::bit_not<> F2;
+    const F2 f2 = F2();
+    assert((f2(0xEA95)  & 0xFFFF ) == 0x156A);
+    assert((f2(0xEA95L) & 0xFFFF ) == 0x156A);
+    assert((f2(0x58D3)  & 0xFFFF ) == 0xA72C);
+    assert((f2(0x58D3L) & 0xFFFF ) == 0xA72C);
+    assert((f2(0)       & 0xFFFF ) == 0xFFFF);
+    assert((f2(0L)      & 0xFFFF ) == 0xFFFF);
+    assert((f2(0xFFFF)  & 0xFFFF ) == 0);
+    assert((f2(0xFFFFL)  & 0xFFFF ) == 0);
+#endif
+}

Modified: libcxx/trunk/test/utilities/function.objects/bitwise.operations/bit_or.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/function.objects/bitwise.operations/bit_or.pass.cpp?rev=187357&r1=187356&r2=187357&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/function.objects/bitwise.operations/bit_or.pass.cpp (original)
+++ libcxx/trunk/test/utilities/function.objects/bitwise.operations/bit_or.pass.cpp Mon Jul 29 09:21:53 2013
@@ -25,4 +25,27 @@ int main()
     assert(f(0x58D3, 0xEA95) == 0xFAD7);
     assert(f(0x58D3, 0) == 0x58D3);
     assert(f(0xFFFF, 0x58D3) == 0xFFFF);
+#if _LIBCPP_STD_VER > 11
+    typedef std::bit_or<> F2;
+    const F2 f2 = F2();
+    assert(f2(0xEA95, 0xEA95) == 0xEA95);
+    assert(f2(0xEA95L, 0xEA95) == 0xEA95);
+    assert(f2(0xEA95, 0xEA95L) == 0xEA95);
+
+    assert(f2(0xEA95, 0x58D3) == 0xFAD7);
+    assert(f2(0xEA95L, 0x58D3) == 0xFAD7);
+    assert(f2(0xEA95, 0x58D3L) == 0xFAD7);
+
+    assert(f2(0x58D3, 0xEA95) == 0xFAD7);
+    assert(f2(0x58D3L, 0xEA95) == 0xFAD7);
+    assert(f2(0x58D3, 0xEA95L) == 0xFAD7);
+
+    assert(f2(0x58D3, 0) == 0x58D3);
+    assert(f2(0x58D3L, 0) == 0x58D3);
+    assert(f2(0x58D3, 0L) == 0x58D3);
+
+    assert(f2(0xFFFF, 0x58D3) == 0xFFFF);
+    assert(f2(0xFFFFL, 0x58D3) == 0xFFFF);
+    assert(f2(0xFFFF, 0x58D3L) == 0xFFFF);
+#endif
 }

Modified: libcxx/trunk/test/utilities/function.objects/bitwise.operations/bit_xor.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/function.objects/bitwise.operations/bit_xor.pass.cpp?rev=187357&r1=187356&r2=187357&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/function.objects/bitwise.operations/bit_xor.pass.cpp (original)
+++ libcxx/trunk/test/utilities/function.objects/bitwise.operations/bit_xor.pass.cpp Mon Jul 29 09:21:53 2013
@@ -25,4 +25,27 @@ int main()
     assert(f(0x58D3, 0xEA95) == 0xB246);
     assert(f(0x58D3, 0) == 0x58D3);
     assert(f(0xFFFF, 0x58D3) == 0xA72C);
+#if _LIBCPP_STD_VER > 11
+    typedef std::bit_xor<> F2;
+    const F2 f2 = F2();
+    assert(f(0xEA95, 0xEA95) == 0);
+    assert(f(0xEA95L, 0xEA95) == 0);
+    assert(f(0xEA95, 0xEA95L) == 0);
+
+    assert(f(0xEA95, 0x58D3) == 0xB246);
+    assert(f(0xEA95L, 0x58D3) == 0xB246);
+    assert(f(0xEA95, 0x58D3L) == 0xB246);
+
+    assert(f(0x58D3, 0xEA95) == 0xB246);
+    assert(f(0x58D3L, 0xEA95) == 0xB246);
+    assert(f(0x58D3, 0xEA95L) == 0xB246);
+
+    assert(f(0x58D3, 0) == 0x58D3);
+    assert(f(0x58D3L, 0) == 0x58D3);
+    assert(f(0x58D3, 0L) == 0x58D3);
+
+    assert(f(0xFFFF, 0x58D3) == 0xA72C);
+    assert(f(0xFFFFL, 0x58D3) == 0xA72C);
+    assert(f(0xFFFF, 0x58D3L) == 0xA72C);
+#endif
 }

Modified: libcxx/trunk/test/utilities/function.objects/comparisons/equal_to.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/function.objects/comparisons/equal_to.pass.cpp?rev=187357&r1=187356&r2=187357&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/function.objects/comparisons/equal_to.pass.cpp (original)
+++ libcxx/trunk/test/utilities/function.objects/comparisons/equal_to.pass.cpp Mon Jul 29 09:21:53 2013
@@ -22,4 +22,12 @@ int main()
     static_assert((std::is_base_of<std::binary_function<int, int, bool>, F>::value), "");
     assert(f(36, 36));
     assert(!f(36, 6));
+#if _LIBCPP_STD_VER > 11
+    typedef std::equal_to<> F2;
+    const F2 f2 = F2();
+    assert(f2(36, 36));
+    assert(!f2(36, 6));
+    assert(f2(36, 36.0));
+    assert(f2(36.0, 36L));
+#endif
 }

Modified: libcxx/trunk/test/utilities/function.objects/comparisons/greater.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/function.objects/comparisons/greater.pass.cpp?rev=187357&r1=187356&r2=187357&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/function.objects/comparisons/greater.pass.cpp (original)
+++ libcxx/trunk/test/utilities/function.objects/comparisons/greater.pass.cpp Mon Jul 29 09:21:53 2013
@@ -23,4 +23,15 @@ int main()
     assert(!f(36, 36));
     assert(f(36, 6));
     assert(!f(6, 36));
+#if _LIBCPP_STD_VER > 11
+    typedef std::greater<> F2;
+    const F2 f2 = F2();
+    assert(!f2(36, 36));
+    assert(f2(36, 6));
+    assert(!f2(6, 36));
+    assert( f2(36, 6.0));
+    assert( f2(36.0, 6));
+    assert(!f2(6, 36.0));
+    assert(!f2(6.0, 36));
+#endif
 }

Modified: libcxx/trunk/test/utilities/function.objects/comparisons/greater_equal.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/function.objects/comparisons/greater_equal.pass.cpp?rev=187357&r1=187356&r2=187357&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/function.objects/comparisons/greater_equal.pass.cpp (original)
+++ libcxx/trunk/test/utilities/function.objects/comparisons/greater_equal.pass.cpp Mon Jul 29 09:21:53 2013
@@ -23,4 +23,15 @@ int main()
     assert(f(36, 36));
     assert(f(36, 6));
     assert(!f(6, 36));
+#if _LIBCPP_STD_VER > 11
+    typedef std::greater_equal<> F2;
+    const F2 f2 = F2();
+    assert(f2(36, 36));
+    assert(f2(36, 6));
+    assert(!f2(6, 36));
+    assert( f2(36, 6.0));
+    assert( f2(36.0, 6));
+    assert(!f2(6, 36.0));
+    assert(!f2(6.0, 36));
+#endif
 }

Modified: libcxx/trunk/test/utilities/function.objects/comparisons/less.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/function.objects/comparisons/less.pass.cpp?rev=187357&r1=187356&r2=187357&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/function.objects/comparisons/less.pass.cpp (original)
+++ libcxx/trunk/test/utilities/function.objects/comparisons/less.pass.cpp Mon Jul 29 09:21:53 2013
@@ -23,4 +23,15 @@ int main()
     assert(!f(36, 36));
     assert(!f(36, 6));
     assert(f(6, 36));
+#if _LIBCPP_STD_VER > 11
+    typedef std::less<> F2;
+    const F2 f2 = F2();
+    assert(!f2(36, 36));
+    assert(!f2(36, 6));
+    assert( f2(6, 36));
+    assert(!f2(36, 6.0));
+    assert(!f2(36.0, 6));
+    assert( f2(6, 36.0));
+    assert( f2(6.0, 36));
+#endif
 }

Modified: libcxx/trunk/test/utilities/function.objects/comparisons/less_equal.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/function.objects/comparisons/less_equal.pass.cpp?rev=187357&r1=187356&r2=187357&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/function.objects/comparisons/less_equal.pass.cpp (original)
+++ libcxx/trunk/test/utilities/function.objects/comparisons/less_equal.pass.cpp Mon Jul 29 09:21:53 2013
@@ -23,4 +23,15 @@ int main()
     assert(f(36, 36));
     assert(!f(36, 6));
     assert(f(6, 36));
+#if _LIBCPP_STD_VER > 11
+    typedef std::less_equal<> F2;
+    const F2 f2 = F2();
+    assert( f2(36, 36));
+    assert(!f2(36, 6));
+    assert( f2(6, 36));
+    assert(!f2(36, 6.0));
+    assert(!f2(36.0, 6));
+    assert( f2(6, 36.0));
+    assert( f2(6.0, 36));
+#endif
 }

Modified: libcxx/trunk/test/utilities/function.objects/comparisons/not_equal_to.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/function.objects/comparisons/not_equal_to.pass.cpp?rev=187357&r1=187356&r2=187357&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/function.objects/comparisons/not_equal_to.pass.cpp (original)
+++ libcxx/trunk/test/utilities/function.objects/comparisons/not_equal_to.pass.cpp Mon Jul 29 09:21:53 2013
@@ -22,4 +22,14 @@ int main()
     static_assert((std::is_base_of<std::binary_function<int, int, bool>, F>::value), "");
     assert(!f(36, 36));
     assert(f(36, 6));
+#if _LIBCPP_STD_VER > 11
+    typedef std::not_equal_to<> F2;
+    const F2 f2 = F2();
+    assert(!f2(36, 36));
+    assert( f2(36, 6));
+    assert( f2(36, 6.0));
+    assert( f2(36.0, 6));
+    assert(!f2(36.0, 36));
+    assert(!f2(36, 36.0));
+#endif
 }

Modified: libcxx/trunk/test/utilities/function.objects/logical.operations/logical_and.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/function.objects/logical.operations/logical_and.pass.cpp?rev=187357&r1=187356&r2=187357&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/function.objects/logical.operations/logical_and.pass.cpp (original)
+++ libcxx/trunk/test/utilities/function.objects/logical.operations/logical_and.pass.cpp Mon Jul 29 09:21:53 2013
@@ -24,4 +24,19 @@ int main()
     assert(!f(36, 0));
     assert(!f(0, 36));
     assert(!f(0, 0));
+#if _LIBCPP_STD_VER > 11
+    typedef std::logical_and<> F2;
+    const F2 f2 = F2();
+    assert( f2(36, 36));
+    assert( f2(36, 36L));
+    assert( f2(36L, 36));
+    assert(!f2(36, 0));
+    assert(!f2(0, 36));
+    assert( f2(36, 36L));
+    assert(!f2(36, 0L));
+    assert(!f2(0, 36L));
+    assert( f2(36L, 36));
+    assert(!f2(36L, 0));
+    assert(!f2(0L, 36));
+#endif
 }

Modified: libcxx/trunk/test/utilities/function.objects/logical.operations/logical_not.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/function.objects/logical.operations/logical_not.pass.cpp?rev=187357&r1=187356&r2=187357&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/function.objects/logical.operations/logical_not.pass.cpp (original)
+++ libcxx/trunk/test/utilities/function.objects/logical.operations/logical_not.pass.cpp Mon Jul 29 09:21:53 2013
@@ -22,4 +22,12 @@ int main()
     static_assert((std::is_base_of<std::unary_function<int, bool>, F>::value), "");
     assert(!f(36));
     assert(f(0));
+#if _LIBCPP_STD_VER > 11
+    typedef std::logical_not<> F2;
+    const F2 f2 = F2();
+    assert(!f2(36));
+    assert( f2(0));
+    assert(!f2(36L));
+    assert( f2(0L));
+#endif
 }

Modified: libcxx/trunk/test/utilities/function.objects/logical.operations/logical_or.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/function.objects/logical.operations/logical_or.pass.cpp?rev=187357&r1=187356&r2=187357&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/function.objects/logical.operations/logical_or.pass.cpp (original)
+++ libcxx/trunk/test/utilities/function.objects/logical.operations/logical_or.pass.cpp Mon Jul 29 09:21:53 2013
@@ -24,4 +24,18 @@ int main()
     assert(f(36, 0));
     assert(f(0, 36));
     assert(!f(0, 0));
+#if _LIBCPP_STD_VER > 11
+    typedef std::logical_or<> F2;
+    const F2 f2 = F2();
+    assert( f2(36, 36));
+    assert( f2(36, 36L));
+    assert( f2(36L, 36));
+    assert( f2(36, 0));
+    assert( f2(0, 36));
+    assert( f2(36, 0L));
+    assert( f2(0, 36L));
+    assert(!f2(0, 0));
+    assert(!f2(0, 0L));
+    assert(!f2(0L, 0));
+#endif
 }





More information about the cfe-commits mailing list