Commit c93fa3ca by Jonathan Wakely Committed by Jonathan Wakely

re PR libstdc++/55861 ([C++11] `std::shared_future::get' is not const-qualified)

	PR libstdc++/55861
	* include/std/future (_State_base::_S_check(const shared_ptr<T>&)):
	Fix return type.
	(__basic_future::_M_get_result()): Const qualify.
	(shared_future::get()): Likewise.
	* testsuite/30_threads/shared_future/members/get.cc: Use const
	objects.

From-SVN: r195314
parent 3122f3b1
2013-01-19 Jonathan Wakely <jwakely.gcc@gmail.com>
PR libstdc++/55861
* include/std/future (_State_base::_S_check(const shared_ptr<T>&)):
Fix return type.
(__basic_future::_M_get_result()): Const qualify.
(shared_future::get()): Likewise.
* testsuite/30_threads/shared_future/members/get.cc: Use const
objects.
2013-01-16 Jonathan Wakely <jwakely.gcc@gmail.com> 2013-01-16 Jonathan Wakely <jwakely.gcc@gmail.com>
PR libstdc++/55043 (again) PR libstdc++/55043 (again)
......
// <future> -*- C++ -*- // <future> -*- C++ -*-
// Copyright (C) 2009-2012 Free Software Foundation, Inc. // Copyright (C) 2009-2013 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the // software; you can redistribute it and/or modify it under the
...@@ -447,7 +447,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -447,7 +447,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
__setter(promise<void>* __prom); __setter(promise<void>* __prom);
template<typename _Tp> template<typename _Tp>
static bool static void
_S_check(const shared_ptr<_Tp>& __p) _S_check(const shared_ptr<_Tp>& __p)
{ {
if (!static_cast<bool>(__p)) if (!static_cast<bool>(__p))
...@@ -583,7 +583,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -583,7 +583,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
protected: protected:
/// Wait for the state to be ready and rethrow any stored exception /// Wait for the state to be ready and rethrow any stored exception
__result_type __result_type
_M_get_result() _M_get_result() const
{ {
_State_base::_S_check(_M_state); _State_base::_S_check(_M_state);
_Result_base& __res = _M_state->wait(); _Result_base& __res = _M_state->wait();
...@@ -794,12 +794,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -794,12 +794,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
/// Retrieving the value /// Retrieving the value
const _Res& const _Res&
get() get() const { return this->_M_get_result()._M_value(); }
{
typename _Base_type::__result_type __r = this->_M_get_result();
_Res& __rs(__r._M_value());
return __rs;
}
}; };
/// Partial specialization for shared_future<R&> /// Partial specialization for shared_future<R&>
...@@ -838,7 +833,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -838,7 +833,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
/// Retrieving the value /// Retrieving the value
_Res& _Res&
get() { return this->_M_get_result()._M_get(); } get() const { return this->_M_get_result()._M_get(); }
}; };
/// Explicit specialization for shared_future<void> /// Explicit specialization for shared_future<void>
...@@ -877,7 +872,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -877,7 +872,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// Retrieving the value // Retrieving the value
void void
get() { this->_M_get_result(); } get() const { this->_M_get_result(); }
}; };
// Now we can define the protected __basic_future constructors. // Now we can define the protected __basic_future constructors.
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
// { dg-require-gthreads "" } // { dg-require-gthreads "" }
// { dg-require-atomic-builtins "" } // { dg-require-atomic-builtins "" }
// Copyright (C) 2009, 2010, 2011, 2012 Free Software Foundation, Inc. // Copyright (C) 2009-2013 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the // software; you can redistribute it and/or modify it under the
...@@ -34,7 +34,7 @@ void test01() ...@@ -34,7 +34,7 @@ void test01()
bool test __attribute__((unused)) = true; bool test __attribute__((unused)) = true;
std::promise<int> p1; std::promise<int> p1;
std::shared_future<int> f1(p1.get_future()); const std::shared_future<int> f1(p1.get_future());
std::shared_future<int> f2(f1); std::shared_future<int> f2(f1);
p1.set_value(value); p1.set_value(value);
...@@ -47,7 +47,7 @@ void test02() ...@@ -47,7 +47,7 @@ void test02()
bool test __attribute__((unused)) = true; bool test __attribute__((unused)) = true;
std::promise<int&> p1; std::promise<int&> p1;
std::shared_future<int&> f1(p1.get_future()); const std::shared_future<int&> f1(p1.get_future());
std::shared_future<int&> f2(f1); std::shared_future<int&> f2(f1);
p1.set_value(value); p1.set_value(value);
...@@ -60,7 +60,7 @@ void test03() ...@@ -60,7 +60,7 @@ void test03()
bool test __attribute__((unused)) = true; bool test __attribute__((unused)) = true;
std::promise<void> p1; std::promise<void> p1;
std::shared_future<void> f1(p1.get_future()); const std::shared_future<void> f1(p1.get_future());
std::shared_future<void> f2(f1); std::shared_future<void> f2(f1);
p1.set_value(); p1.set_value();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment