]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR libstdc++/85671 allow copy elision in path concatenation
authorJonathan Wakely <jwakely@redhat.com>
Wed, 4 Jul 2018 13:59:06 +0000 (14:59 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Wed, 4 Jul 2018 13:59:06 +0000 (14:59 +0100)
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/experimental/bits/fs_path.h (operator/): Likewise.

From-SVN: r262404

libstdc++-v3/ChangeLog
libstdc++-v3/include/experimental/bits/fs_path.h

index 9ca215ed077725be17d2f213657588c89e93c0b2..2f874dfe5f25191f161791268536c906725e63c1 100644 (file)
@@ -1,5 +1,11 @@
 2018-07-04  Jonathan Wakely  <jwakely@redhat.com>
 
+       Backport from mainline
+       2018-05-07  Jonathan Wakely  <jwakely@redhat.com>
+
+       PR libstdc++/85671
+       * include/experimental/bits/fs_path.h (operator/): Likewise.
+
        Backport from mainline
        2018-06-14  Daniel Trebbien <dtrebbien@gmail.com>
                    Jonathan Wakely  <jwakely@redhat.com>
index 512167f6f2d713a53c6361686f7659c23f4423e2..aa4949c5e24b11f43ba9dd83017ca26b94edec36 100644 (file)
@@ -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<typename _CharT, typename _Traits>