summaryrefslogtreecommitdiffstats
path: root/libstdc++-v3/include/std/utility
diff options
context:
space:
mode:
authorredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>2013-05-18 16:18:35 +0000
committerredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>2013-05-18 16:18:35 +0000
commitc8ae75b7453363883f0e8fab1f7657f4b0d50fe6 (patch)
treef2b2b59742efeb4164b966ee4103f5f852051c65 /libstdc++-v3/include/std/utility
parentce5e50454e25423bede36e3f7c71ae44e4a0b570 (diff)
downloadppe42-gcc-c8ae75b7453363883f0e8fab1f7657f4b0d50fe6.tar.gz
ppe42-gcc-c8ae75b7453363883f0e8fab1f7657f4b0d50fe6.zip
* include/std/utility (exchange): Define.
* testsuite/20_util/exchange/1.cc: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@199061 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/include/std/utility')
-rw-r--r--libstdc++-v3/include/std/utility12
1 files changed, 12 insertions, 0 deletions
diff --git a/libstdc++-v3/include/std/utility b/libstdc++-v3/include/std/utility
index 8142ea466e4..ee8c6b19609 100644
--- a/libstdc++-v3/include/std/utility
+++ b/libstdc++-v3/include/std/utility
@@ -152,6 +152,18 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
get(const std::pair<_Tp1, _Tp2>& __in) noexcept
{ return __pair_get<_Int>::__const_get(__in); }
+#if __cplusplus > 201103L
+ /// Assign @p __new_val to @p __obj and return its previous value.
+ template <class _Tp, class _Up = _Tp>
+ inline _Tp
+ exchange(_Tp& __obj, _Up&& __new_val)
+ {
+ _Tp __old_val = std::move(__obj);
+ __obj = std::forward<_Up>(__new_val);
+ return __old_val;
+ }
+#endif
+
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
OpenPOWER on IntegriCloud