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
This commit is contained in:
Jonathan Wakely 2018-05-07 18:26:28 +01:00 committed by Jonathan Wakely
parent 6fa8c51f72
commit a989f6378b
3 changed files with 16 additions and 2 deletions

View File

@ -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

View File

@ -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>

View File

@ -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>