This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Attempt to make std::pair piecewise constructor noexcept


On 21/12/18 18:21 +0100, François Dumont wrote:
On 12/21/18 3:00 PM, Ville Voutilainen wrote:
On Fri, 21 Dec 2018 at 15:47, Jonathan Wakely <jwakely@redhat.com> wrote:
On 16/12/18 18:48 +0100, François Dumont wrote:
@@ -372,7 +361,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        second(std::forward<_U2>(__p.second)) { }

      template<typename... _Args1, typename... _Args2>
-        pair(piecewise_construct_t, tuple<_Args1...>, tuple<_Args2...>);
+      pair(piecewise_construct_t,
+           tuple<_Args1...> __first, tuple<_Args2...> __second)
+      noexcept( noexcept(
+        pair(declval<tuple<_Args1...>&>(), declval<tuple<_Args2...>&>(),
+             declval<typename _Build_index_tuple<sizeof...(_Args1)>::__type>(),
+             declval<typename _Build_index_tuple<sizeof...(_Args2)>::__type>())) )
+      : pair(__first, __second,
+             typename _Build_index_tuple<sizeof...(_Args1)>::__type(),
+             typename _Build_index_tuple<sizeof...(_Args2)>::__type())
+      { }
Surely just:

      noexcept(
        is_nothrow_constructible<_T1, _Args1...>
        &&
        is_nothrow_constructible<_T2, _Args2...>
      )

?
Correct. Piecewise construction will end up doing that anyway, and we
know it will.

Indeed, it is simpler and avoids moving a lot of code in different headers. It just make hypothesis on implementation details which I usually try to avoid.

It's not an implementation detail, it's what the constructor is
required to do by the standard. The whole point of that constructor is
to construct the first member with the elements of the first tuple,
and construct the second member with the elements of the second tuple.
So the constructor arguments are the tuple elements, and their types
are _Args1... and _Args2....

Good point for anyone willing to push such a patch. But not me as I have no interest to do so anymore.

OK.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]