This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [Patch] Implementation of n3793 <experimental/optional>
- From: Luc Danton <lucdanton at free dot fr>
- To: Paolo Carlini <paolo dot carlini at oracle dot com>, Jonathan Wakely <jwakely dot gcc at gmail dot com>
- Cc: libstdc++ <libstdc++ at gcc dot gnu dot org>, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Sun, 03 Nov 2013 01:39:30 +0100
- Subject: Re: [Patch] Implementation of n3793 <experimental/optional>
- Authentication-results: sourceware.org; auth=none
- References: <5260CFE7 dot 7000808 at free dot fr> <CAH6eHdTs43dT6yY=tfL9mfWHKAR3yZ-2j02Scs8FW4zUE=L6=w at mail dot gmail dot com> <52729DF5 dot 6020806 at free dot fr> <CAH6eHdQ9bwMD0Awh9bivCTb83na8i1od6pyqRMULmY48a2-x-A at mail dot gmail dot com> <4589CEDD-15F5-4E9F-9975-196EF10EEA20 at oracle dot com> <52753C68 dot 4050708 at free dot fr> <d15f0e1a-b8c7-4760-a93d-03d026bfe65d at email dot android dot com> <52757A20 dot 50900 at free dot fr> <89e21fc2-b9ee-499d-95ea-f1b7ec63155a at email dot android dot com>
On 2013-11-02 23:31, Paolo Carlini wrote:
In general we are very careful with code bloat, but free functions which just forward to other functions should be definiyely inline, otherwise typically at widely used optimization levels like -O2 users get suboptimal performance for no reason. But please feel free to experiment and report your findings on the mailing list!
Paolo
After review, the free functions that only ever forward to something
else and are not implicitly inline appear to be that
__constexpr_addressof overload and non-member swap. Here's a patch
(against master) that marks them inline, all tests pass. I briefly and
casually attempted to notice any effect, but to be honest in my smallish
testcases GCC appeared to already see through everything.
>From 0175e61f3295159fe7ac2fefec05b829ecd6bc4d Mon Sep 17 00:00:00 2001
From: Michael Brune <lucdanton@free.fr>
Date: Sun, 3 Nov 2013 01:37:16 +0100
Subject: [PATCH] Marked some forwarding free functions as inline that weren't
already.
---
libstdc++-v3/include/experimental/optional | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libstdc++-v3/include/experimental/optional b/libstdc++-v3/include/experimental/optional
index 5915892..06e0f29 100644
--- a/libstdc++-v3/include/experimental/optional
+++ b/libstdc++-v3/include/experimental/optional
@@ -157,7 +157,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
*/
template<typename _Tp, typename enable_if<_Has_addressof<_Tp>::value,
int>::type...>
- _Tp* __constexpr_addressof(_Tp& __t)
+ inline _Tp* __constexpr_addressof(_Tp& __t)
{ return std::__addressof(__t); }
/**
@@ -790,7 +790,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// [X.Y.11]
template<typename _Tp>
- void
+ inline void
swap(optional<_Tp>& __lhs, optional<_Tp>& __rhs)
noexcept(noexcept(__lhs.swap(__rhs)))
{ __lhs.swap(__rhs); }
--
1.8.1.2