diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2018-05-07 18:26:28 +0100 |
---|---|---|
committer | Jonathan Wakely <redi@gcc.gnu.org> | 2018-05-07 18:26:28 +0100 |
commit | a989f6378b1b08aa3145c7bd77477282ddc5e553 (patch) | |
tree | 22ec0214ed49d618214ea821153e5f60692eb169 | |
parent | 6fa8c51f72ada5e467f5e3b9552ab22ef68dcfd3 (diff) | |
download | gcc-a989f6378b1b08aa3145c7bd77477282ddc5e553.zip gcc-a989f6378b1b08aa3145c7bd77477282ddc5e553.tar.gz gcc-a989f6378b1b08aa3145c7bd77477282ddc5e553.tar.bz2 |
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.
PR libstdc++/85671
* include/bits/fs_path.h (operator/): Permit copy elision.
* include/experimental/bits/fs_path.h (operator/): Likewise.
From-SVN: r260009
-rw-r--r-- | libstdc++-v3/ChangeLog | 6 | ||||
-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, 16 insertions, 2 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 94f08c2..cdbc44e 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,9 @@ +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. + 2018-05-07 Edward Smith-Rowland <3dw4rd@verizon.net> Moar PR libstdc++/80506 diff --git a/libstdc++-v3/include/bits/fs_path.h b/libstdc++-v3/include/bits/fs_path.h index 31c34d6..6703e91 100644 --- a/libstdc++-v3/include/bits/fs_path.h +++ b/libstdc++-v3/include/bits/fs_path.h @@ -552,7 +552,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 456452b..3b4011e 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> |