[libcxx] r199848 - Const qualify __mem_fn call operator

Peter Collingbourne peter at pcc.me.uk
Wed Jan 22 14:56:52 PST 2014


Author: pcc
Date: Wed Jan 22 16:56:52 2014
New Revision: 199848

URL: http://llvm.org/viewvc/llvm-project?rev=199848&view=rev
Log:
Const qualify __mem_fn call operator

QOI improvement.

Differential Revision: http://llvm-reviews.chandlerc.com/D2059

Modified:
    libcxx/trunk/include/__functional_03
    libcxx/trunk/include/functional
    libcxx/trunk/test/utilities/function.objects/func.memfn/member_data.pass.cpp
    libcxx/trunk/test/utilities/function.objects/func.memfn/member_function.pass.cpp
    libcxx/trunk/test/utilities/function.objects/func.memfn/member_function_const.pass.cpp
    libcxx/trunk/test/utilities/function.objects/func.memfn/member_function_const_volatile.pass.cpp
    libcxx/trunk/test/utilities/function.objects/func.memfn/member_function_volatile.pass.cpp

Modified: libcxx/trunk/include/__functional_03
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__functional_03?rev=199848&r1=199847&r2=199848&view=diff
==============================================================================
--- libcxx/trunk/include/__functional_03 (original)
+++ libcxx/trunk/include/__functional_03 Wed Jan 22 16:56:52 2014
@@ -33,28 +33,28 @@ public:
     // invoke
 
     typename __invoke_return<type>::type
-       operator() ()
+       operator() () const
        {
            return __invoke(__f_);
        }
 
     template <class _A0>
        typename __invoke_return0<type, _A0>::type
-          operator() (_A0& __a0)
+          operator() (_A0& __a0) const
           {
               return __invoke(__f_, __a0);
           }
 
     template <class _A0, class _A1>
        typename __invoke_return1<type, _A0, _A1>::type
-          operator() (_A0& __a0, _A1& __a1)
+          operator() (_A0& __a0, _A1& __a1) const
           {
               return __invoke(__f_, __a0, __a1);
           }
 
     template <class _A0, class _A1, class _A2>
        typename __invoke_return2<type, _A0, _A1, _A2>::type
-          operator() (_A0& __a0, _A1& __a1, _A2& __a2)
+          operator() (_A0& __a0, _A1& __a1, _A2& __a2) const
           {
               return __invoke(__f_, __a0, __a1, __a2);
           }

Modified: libcxx/trunk/include/functional
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/functional?rev=199848&r1=199847&r2=199848&view=diff
==============================================================================
--- libcxx/trunk/include/functional (original)
+++ libcxx/trunk/include/functional Wed Jan 22 16:56:52 2014
@@ -1221,7 +1221,7 @@ public:
     template <class... _ArgTypes>
        _LIBCPP_INLINE_VISIBILITY
        typename __invoke_return<type, _ArgTypes...>::type
-          operator() (_ArgTypes&&... __args)
+          operator() (_ArgTypes&&... __args) const
           {
               return __invoke(__f_, _VSTD::forward<_ArgTypes>(__args)...);
           }

Modified: libcxx/trunk/test/utilities/function.objects/func.memfn/member_data.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/function.objects/func.memfn/member_data.pass.cpp?rev=199848&r1=199847&r2=199848&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/function.objects/func.memfn/member_data.pass.cpp (original)
+++ libcxx/trunk/test/utilities/function.objects/func.memfn/member_data.pass.cpp Wed Jan 22 16:56:52 2014
@@ -32,6 +32,8 @@ test(F f)
     assert(a.data_ == 6);
     const A* cap = ap;
     assert(f(cap) == f(ap));
+    const F& cf = f;
+    assert(cf(ap) == f(ap));
     }
 }
 

Modified: libcxx/trunk/test/utilities/function.objects/func.memfn/member_function.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/function.objects/func.memfn/member_function.pass.cpp?rev=199848&r1=199847&r2=199848&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/function.objects/func.memfn/member_function.pass.cpp (original)
+++ libcxx/trunk/test/utilities/function.objects/func.memfn/member_function.pass.cpp Wed Jan 22 16:56:52 2014
@@ -31,6 +31,8 @@ test0(F f)
     assert(f(a) == 'a');
     A* ap = &a;
     assert(f(ap) == 'a');
+    const F& cf = f;
+    assert(cf(ap) == 'a');
     }
 }
 
@@ -43,6 +45,8 @@ test1(F f)
     assert(f(a, 1) == 'b');
     A* ap = &a;
     assert(f(ap, 2) == 'b');
+    const F& cf = f;
+    assert(cf(ap, 2) == 'b');
     }
 }
 
@@ -55,6 +59,8 @@ test2(F f)
     assert(f(a, 1, 2) == 'c');
     A* ap = &a;
     assert(f(ap, 2, 3.5) == 'c');
+    const F& cf = f;
+    assert(cf(ap, 2, 3.5) == 'c');
     }
 }
 

Modified: libcxx/trunk/test/utilities/function.objects/func.memfn/member_function_const.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/function.objects/func.memfn/member_function_const.pass.cpp?rev=199848&r1=199847&r2=199848&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/function.objects/func.memfn/member_function_const.pass.cpp (original)
+++ libcxx/trunk/test/utilities/function.objects/func.memfn/member_function_const.pass.cpp Wed Jan 22 16:56:52 2014
@@ -33,6 +33,8 @@ test0(F f)
     assert(f(ap) == 'a');
     const A* cap = &a;
     assert(f(cap) == 'a');
+    const F& cf = f;
+    assert(cf(ap) == 'a');
     }
 }
 
@@ -47,6 +49,8 @@ test1(F f)
     assert(f(ap, 2) == 'b');
     const A* cap = &a;
     assert(f(cap, 2) == 'b');
+    const F& cf = f;
+    assert(cf(ap, 2) == 'b');
     }
 }
 
@@ -61,6 +65,8 @@ test2(F f)
     assert(f(ap, 2, 3.5) == 'c');
     const A* cap = &a;
     assert(f(cap, 2, 3.5) == 'c');
+    const F& cf = f;
+    assert(cf(ap, 2, 3.5) == 'c');
     }
 }
 

Modified: libcxx/trunk/test/utilities/function.objects/func.memfn/member_function_const_volatile.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/function.objects/func.memfn/member_function_const_volatile.pass.cpp?rev=199848&r1=199847&r2=199848&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/function.objects/func.memfn/member_function_const_volatile.pass.cpp (original)
+++ libcxx/trunk/test/utilities/function.objects/func.memfn/member_function_const_volatile.pass.cpp Wed Jan 22 16:56:52 2014
@@ -33,6 +33,8 @@ test0(F f)
     assert(f(ap) == 'a');
     const volatile A* cap = &a;
     assert(f(cap) == 'a');
+    const F& cf = f;
+    assert(cf(ap) == 'a');
     }
 }
 
@@ -47,6 +49,8 @@ test1(F f)
     assert(f(ap, 2) == 'b');
     const volatile A* cap = &a;
     assert(f(cap, 2) == 'b');
+    const F& cf = f;
+    assert(cf(ap, 2) == 'b');
     }
 }
 
@@ -61,6 +65,8 @@ test2(F f)
     assert(f(ap, 2, 3.5) == 'c');
     const volatile A* cap = &a;
     assert(f(cap, 2, 3.5) == 'c');
+    const F& cf = f;
+    assert(cf(ap, 2, 3.5) == 'c');
     }
 }
 

Modified: libcxx/trunk/test/utilities/function.objects/func.memfn/member_function_volatile.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/function.objects/func.memfn/member_function_volatile.pass.cpp?rev=199848&r1=199847&r2=199848&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/function.objects/func.memfn/member_function_volatile.pass.cpp (original)
+++ libcxx/trunk/test/utilities/function.objects/func.memfn/member_function_volatile.pass.cpp Wed Jan 22 16:56:52 2014
@@ -33,6 +33,8 @@ test0(F f)
     assert(f(ap) == 'a');
     volatile A* cap = &a;
     assert(f(cap) == 'a');
+    const F& cf = f;
+    assert(cf(ap) == 'a');
     }
 }
 
@@ -47,6 +49,8 @@ test1(F f)
     assert(f(ap, 2) == 'b');
     volatile A* cap = &a;
     assert(f(cap, 2) == 'b');
+    const F& cf = f;
+    assert(cf(ap, 2) == 'b');
     }
 }
 
@@ -61,6 +65,8 @@ test2(F f)
     assert(f(ap, 2, 3.5) == 'c');
     volatile A* cap = &a;
     assert(f(cap, 2, 3.5) == 'c');
+    const F& cf = f;
+    assert(cf(ap, 2, 3.5) == 'c');
     }
 }
 





More information about the cfe-commits mailing list