From: Jonathan Wakely <jwakely@redhat.com>
To: "François Dumont" <frs.dumont@gmail.com>
Cc: libstdc++@gcc.gnu.org, gcc-patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] 77864 Fix noexcept conditions for map/set default constructors
Date: Thu, 06 Oct 2016 21:34:00 -0000 [thread overview]
Message-ID: <20161006213408.GU29482@redhat.com> (raw)
In-Reply-To: <4d30deb3-8720-2aa6-d0f2-94f6fca44825@gmail.com>
On 06/10/16 22:17 +0200, François Dumont wrote:
>Another approach is to rely on existing compiler ability to compute
>conditional noexcept when defaulting implementations. This is what I
>have done in this patch.
>
>The new default constructor on _Rb_tree_node_base is not a problem as
>it is not used to build _Rb_tree_node.
Why not?
>I'll try to do the same for copy constructor/assignment and move
>constructor/assignment.
We need to make sure we don't change whether any of those operations
are trivial (which shouldn't be a problem for copy/move, because they
are definitely very non-trivial and will stay that way!)
Does this change the default constructors from non-trivial to trivial?
>--- a/libstdc++-v3/include/bits/stl_tree.h
>+++ b/libstdc++-v3/include/bits/stl_tree.h
>@@ -108,6 +108,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
> _Base_ptr _M_left;
> _Base_ptr _M_right;
>
>+ _Rb_tree_node_base() _GLIBCXX_NOEXCEPT
>+ : _M_color(_S_red), _M_parent(0), _M_left(this), _M_right(this)
>+ { }
>+
> static _Base_ptr
> _S_minimum(_Base_ptr __x) _GLIBCXX_NOEXCEPT
> {
Another option would be:
struct _Head_node : _Rb_tree_node_base {
_Head_node() {
_M_color = _S_red;
_M_parent = _Base_ptr();
_M_left = _M_right = this;
}
};
>@@ -603,23 +607,33 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
> {
> _Key_compare _M_key_compare;
> _Rb_tree_node_base _M_header;
_Head_node _M_header;
That way *only* this node gets the zero-initialization, not all node
bases.
With either solution we can get rid of _M_header() in every
ctor-initializer-list.
>+#if __cplusplus < 201103L
> size_type _M_node_count; // Keeps track of size of tree.
>+#else
>+ size_type _M_node_count = 0; // Keeps track of size of tree.
>+#endif
>
>+#if __cplusplus < 201103L
> _Rb_tree_impl()
> : _Node_allocator(), _M_key_compare(), _M_header(),
> _M_node_count(0)
>- { _M_initialize(); }
>+ { }
>+#else
>+ _Rb_tree_impl() = default;
>+#endif
>
> _Rb_tree_impl(const _Key_compare& __comp, const _Node_allocator& __a)
>- : _Node_allocator(__a), _M_key_compare(__comp), _M_header(),
>- _M_node_count(0)
>- { _M_initialize(); }
>+ : _Node_allocator(__a), _M_key_compare(__comp), _M_header()
>+#if __cplusplus < 201103L
>+ , _M_node_count(0)
>+#endif
Doing this conditionally seems pointless, why not just set it here
unconditionally?
next prev parent reply other threads:[~2016-10-06 21:34 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-05 11:56 Jonathan Wakely
2016-10-05 12:11 ` Marc Glisse
2016-10-05 12:13 ` Jonathan Wakely
2016-10-06 20:17 ` François Dumont
2016-10-06 21:34 ` Jonathan Wakely [this message]
2016-10-08 20:55 ` François Dumont
2016-10-09 15:14 ` Jonathan Wakely
2016-10-09 15:38 ` Jonathan Wakely
2016-10-10 19:24 ` François Dumont
[not found] ` <CAPQZVxvFJb4gwj2cpxvTPZgBtiyZyviqz0iLhW4sAY6rSrjn6w@mail.gmail.com>
2016-10-10 21:01 ` Tim Song
2016-10-12 20:36 ` François Dumont
2016-10-12 21:26 ` Tim Song
2016-10-23 13:54 ` François Dumont
2016-10-24 11:03 ` Jonathan Wakely
2016-10-25 19:55 ` François Dumont
2016-10-26 8:22 ` Jonathan Wakely
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20161006213408.GU29482@redhat.com \
--to=jwakely@redhat.com \
--cc=frs.dumont@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=libstdc++@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).