From c8fbe558101c52bf3ece5d71634c5380da73c310 Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Wed, 4 Jul 2018 14:59:06 +0100 Subject: [PATCH] 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 PR libstdc++/85671 * include/experimental/bits/fs_path.h (operator/): Likewise. From-SVN: r262404 --- libstdc++-v3/ChangeLog | 6 ++++++ libstdc++-v3/include/experimental/bits/fs_path.h | 6 +++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 9ca215ed0777..2f874dfe5f25 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,11 @@ 2018-07-04 Jonathan Wakely + Backport from mainline + 2018-05-07 Jonathan Wakely + + PR libstdc++/85671 + * include/experimental/bits/fs_path.h (operator/): Likewise. + Backport from mainline 2018-06-14 Daniel Trebbien Jonathan Wakely diff --git a/libstdc++-v3/include/experimental/bits/fs_path.h b/libstdc++-v3/include/experimental/bits/fs_path.h index 512167f6f2d7..aa4949c5e24b 100644 --- a/libstdc++-v3/include/experimental/bits/fs_path.h +++ b/libstdc++-v3/include/experimental/bits/fs_path.h @@ -509,7 +509,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 -- 2.47.2