diff mbox

Add 'const' to helper functors for std::promise etc.

Message ID 20141210003938.GI3134@redhat.com
State New
Headers show

Commit Message

Jonathan Wakely Dec. 10, 2014, 12:39 a.m. UTC
Thanks to Geoff Romer for suggesting this change, which might be
needed if we change std::function to only be able to call const
operator() overloads for C++17.

Tested x86_64-linux and powerpc64-linux, committed to trunk.
diff mbox

Patch

commit d4eb711ad60cf2925d8f8f6c622918c648a51e13
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Wed Dec 10 00:22:08 2014 +0000

    	* include/std/future (__future_base::_Setter::operator(),
    	__future_base::_Task_setter::operator()): Make call operators const.

diff --git a/libstdc++-v3/include/std/future b/libstdc++-v3/include/std/future
index 157ceb3..31aaf98 100644
--- a/libstdc++-v3/include/std/future
+++ b/libstdc++-v3/include/std/future
@@ -455,7 +455,7 @@  _GLIBCXX_BEGIN_NAMESPACE_VERSION
               "Invalid specialisation");
 
 	  // Used by std::promise to copy construct the result.
-          typename promise<_Res>::_Ptr_type operator()()
+          typename promise<_Res>::_Ptr_type operator()() const
           {
             _State_baseV2::_S_check(_M_promise->_M_future);
             _M_promise->_M_storage->_M_set(*_M_arg);
@@ -470,7 +470,7 @@  _GLIBCXX_BEGIN_NAMESPACE_VERSION
         struct _Setter<_Res, _Res&&>
         {
 	  // Used by std::promise to move construct the result.
-          typename promise<_Res>::_Ptr_type operator()()
+          typename promise<_Res>::_Ptr_type operator()() const
           {
             _State_baseV2::_S_check(_M_promise->_M_future);
             _M_promise->_M_storage->_M_set(std::move(*_M_arg));
@@ -487,7 +487,7 @@  _GLIBCXX_BEGIN_NAMESPACE_VERSION
         struct _Setter<_Res, __exception_ptr_tag>
         {
 	  // Used by std::promise to store an exception as the result.
-          typename promise<_Res>::_Ptr_type operator()()
+          typename promise<_Res>::_Ptr_type operator()() const
           {
             _State_baseV2::_S_check(_M_promise->_M_future);
             _M_promise->_M_storage->_M_error = *_M_ex;
@@ -1286,7 +1286,7 @@  _GLIBCXX_BEGIN_NAMESPACE_VERSION
   template<>
     struct __future_base::_State_base::_Setter<void, void>
     {
-      promise<void>::_Ptr_type operator()()
+      promise<void>::_Ptr_type operator()() const
       {
         _State_base::_S_check(_M_promise->_M_future);
         return std::move(_M_promise->_M_storage);
@@ -1310,7 +1310,7 @@  _GLIBCXX_BEGIN_NAMESPACE_VERSION
     struct __future_base::_Task_setter
     {
       // Invoke the function and provide the result to the caller.
-      _Ptr_type operator()()
+      _Ptr_type operator()() const
       {
 	__try
 	  {
@@ -1333,7 +1333,7 @@  _GLIBCXX_BEGIN_NAMESPACE_VERSION
   template<typename _Ptr_type, typename _Fn>
     struct __future_base::_Task_setter<_Ptr_type, _Fn, void>
     {
-      _Ptr_type operator()()
+      _Ptr_type operator()() const
       {
 	__try
 	  {