diff options
author | redi <redi@138bc75d-0d04-0410-961f-82ee72b054a4> | 2018-07-04 11:44:56 +0000 |
---|---|---|
committer | redi <redi@138bc75d-0d04-0410-961f-82ee72b054a4> | 2018-07-04 11:44:56 +0000 |
commit | 57f5b7a6f4fbef6241658c1dc93390c60ead42b6 (patch) | |
tree | cea810b8de3a1cf31a8109534ba863c40ec17a4f | |
parent | 045fca19c27b73f1c9b823d0686b379a95450e13 (diff) |
PR libstdc++/85671 allow copy elision in path concatenation
By performing the /= operation on a named local variable instead of a
temporary the copy made for the return value can be elided.
Backport from mainline
2018-05-07 Jonathan Wakely <jwakely@redhat.com>
PR libstdc++/85671
* include/bits/fs_path.h (operator/): Permit copy elision.
* include/experimental/bits/fs_path.h (operator/): Likewise.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-8-branch@262388 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | libstdc++-v3/ChangeLog | 7 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/fs_path.h | 6 | ||||
-rw-r--r-- | libstdc++-v3/include/experimental/bits/fs_path.h | 6 |
3 files changed, 17 insertions, 2 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index bada95b4f4df..eebefd44be47 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,6 +1,13 @@ 2018-07-04 Jonathan Wakely <jwakely@redhat.com> Backport from mainline + 2018-05-07 Jonathan Wakely <jwakely@redhat.com> + + PR libstdc++/85671 + * include/bits/fs_path.h (operator/): Permit copy elision. + * include/experimental/bits/fs_path.h (operator/): Likewise. + + Backport from mainline 2018-06-14 Daniel Trebbien <dtrebbien@gmail.com> Jonathan Wakely <jwakely@redhat.com> diff --git a/libstdc++-v3/include/bits/fs_path.h b/libstdc++-v3/include/bits/fs_path.h index 3921d17be688..51af28916474 100644 --- a/libstdc++-v3/include/bits/fs_path.h +++ b/libstdc++-v3/include/bits/fs_path.h @@ -549,7 +549,11 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 /// Append one path to another inline path operator/(const path& __lhs, const path& __rhs) - { return path(__lhs) /= __rhs; } + { + path __result(__lhs); + __result /= __rhs; + return __result; + } /// Write a path to a stream template<typename _CharT, typename _Traits> diff --git a/libstdc++-v3/include/experimental/bits/fs_path.h b/libstdc++-v3/include/experimental/bits/fs_path.h index 0e5777e8ac62..ada7c1791aa6 100644 --- a/libstdc++-v3/include/experimental/bits/fs_path.h +++ b/libstdc++-v3/include/experimental/bits/fs_path.h @@ -510,7 +510,11 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 /// Append one path to another inline path operator/(const path& __lhs, const path& __rhs) - { return path(__lhs) /= __rhs; } + { + path __result(__lhs); + __result /= __rhs; + return __result; + } /// Write a path to a stream template<typename _CharT, typename _Traits> |