From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1720) id 32258385701B; Mon, 9 Aug 2021 18:49:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 32258385701B MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="utf-8" From: =?utf-8?b?RnJhbuCkpeCkiG9pcyBEdW1vbnQ=?= To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r12-2824] libstdc++: [_GLIBCXX_DEBUG] Avoid allocator operator== when always equal X-Act-Checkin: gcc X-Git-Author: =?utf-8?q?Fran=C3=A7ois_Dumont?= X-Git-Refname: refs/heads/master X-Git-Oldrev: d55d3f5b04e81b79f34ccf23f7e2c1e736ad3b0d X-Git-Newrev: 1354603bf7d2ef8cd0cb1f76e801732020502987 Message-Id: <20210809184915.32258385701B@sourceware.org> Date: Mon, 9 Aug 2021 18:49:15 +0000 (GMT) X-BeenThere: libstdc++-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Aug 2021 18:49:15 -0000 https://gcc.gnu.org/g:1354603bf7d2ef8cd0cb1f76e801732020502987 commit r12-2824-g1354603bf7d2ef8cd0cb1f76e801732020502987 Author: François Dumont Date: Mon Aug 9 11:55:43 2021 +0200 libstdc++: [_GLIBCXX_DEBUG] Avoid allocator operator== when always equal Use std::allocator_traits::is_always_equal to find out if we need to compare allocator instances on safe container allocator aware move constructor. libstdc++-v3/ChangeLog: * include/debug/safe_container.h (_Safe_container(_Safe_container&&, const _Alloc&, std::true_type)): New. (_Safe_container(_Safe_container&&, const _Alloc&, std::false_type)): New. (_Safe_container(_Safe_container&&, const _Alloc&)): Use latters. Diff: --- libstdc++-v3/include/debug/safe_container.h | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/libstdc++-v3/include/debug/safe_container.h b/libstdc++-v3/include/debug/safe_container.h index d9636c29e9b..97c47167fe8 100644 --- a/libstdc++-v3/include/debug/safe_container.h +++ b/libstdc++-v3/include/debug/safe_container.h @@ -57,7 +57,12 @@ namespace __gnu_debug _Safe_container(const _Safe_container&) = default; _Safe_container(_Safe_container&&) = default; - _Safe_container(_Safe_container&& __x, const _Alloc& __a) + private: + _Safe_container(_Safe_container&& __x, const _Alloc&, std::true_type) + : _Safe_container(std::move(__x)) + { } + + _Safe_container(_Safe_container&& __x, const _Alloc& __a, std::false_type) : _Safe_container() { if (__x._M_cont().get_allocator() == __a) @@ -65,6 +70,12 @@ namespace __gnu_debug else __x._M_invalidate_all(); } + + protected: + _Safe_container(_Safe_container&& __x, const _Alloc& __a) + : _Safe_container(std::move(__x), __a, + typename std::allocator_traits<_Alloc>::is_always_equal{}) + { } #endif public: