From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 59562 invoked by alias); 25 Jul 2018 19:42:55 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 59519 invoked by uid 89); 25 Jul 2018 19:42:54 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.5 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPF_PASS,TBC autolearn=ham version=3.3.2 spammy= X-HELO: mail-wm0-f43.google.com Received: from mail-wm0-f43.google.com (HELO mail-wm0-f43.google.com) (74.125.82.43) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 25 Jul 2018 19:42:52 +0000 Received: by mail-wm0-f43.google.com with SMTP id y9-v6so6322965wma.5; Wed, 25 Jul 2018 12:42:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=to:from:subject:message-id:date:user-agent:mime-version :content-language; bh=b/PNQriIHHTG3N9t9h7stHU92kH9FaEQ2x1zXe9gsAQ=; b=N3zHnH3jPEAFZ6R3gdbgpfKHJmdC+YDni4+78glTJXmq4Y7Cp/wesvbS/AIRMURBUY Ep86wYYxCtfXX4HMivSATfvK0FtO8itsHD8ftEFjXn3YiiLwjA61PjX0vzqWVPntZ0vv 7DUi7ZufWl+JYJfpmH/3uj83/etjgjkJJf1gcd49U01sDZd1tcS0WXb4AGTHEov0GfgT uQw9OG+ZX6sCvKug9LGW73q3K4rw8pFNY2PYjt55KID6N9jiDWiE/XP+4DyjcPWW6jKs kF3NMOZiZ+6jRcv6II1zQ05rbMHo6hesgm3z7WbIJ7x3A4iYAWQqeiYDmDNQTo91SbVX B0zw== Return-Path: Received: from [192.168.0.22] (arf62-1-82-237-250-248.fbx.proxad.net. [82.237.250.248]) by smtp.googlemail.com with ESMTPSA id s2-v6sm4593283wrn.83.2018.07.25.12.42.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Jul 2018 12:42:49 -0700 (PDT) To: "libstdc++@gcc.gnu.org" , gcc-patches From: =?UTF-8?Q?Fran=c3=a7ois_Dumont?= Subject: Share ebo helper throughout lib Message-ID: <1b6ec4c9-cdf9-2b7c-f263-185e70029d54@gmail.com> Date: Wed, 25 Jul 2018 19:42:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------3127696E20F7895E81E793AB" X-SW-Source: 2018-07/txt/msg01570.txt.bz2 This is a multi-part message in MIME format. --------------3127696E20F7895E81E793AB Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-length: 393 Hi     It has already been noticed that there are 2 ebo helpers in the lib. Here is a patch to use 1.     * include/bits/ebo_helper.h: New.     * include/Makefile.am: Add latter.     * include/Makefile.in: Regenerate.     * include/bits/hashtable_policy.h: Adapt.     * include/bits/shared_ptr_base.h: Adapt. Tested under linux x86_64. Ok to commit ? François --------------3127696E20F7895E81E793AB Content-Type: text/x-patch; name="ebo_helper.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="ebo_helper.patch" Content-length: 8043 diff --git a/libstdc++-v3/include/Makefile.am b/libstdc++-v3/include/Makefile.am index 70db3cb..98c1a6c 100644 --- a/libstdc++-v3/include/Makefile.am +++ b/libstdc++-v3/include/Makefile.am @@ -105,6 +105,7 @@ bits_headers = \ ${bits_srcdir}/concept_check.h \ ${bits_srcdir}/cpp_type_traits.h \ ${bits_srcdir}/deque.tcc \ + ${bits_srcdir}/ebo_helper.h \ ${bits_srcdir}/enable_special_members.h \ ${bits_srcdir}/forward_list.h \ ${bits_srcdir}/forward_list.tcc \ diff --git a/libstdc++-v3/include/Makefile.in b/libstdc++-v3/include/Makefile.in index 0e1cbe4..35093bc 100644 --- a/libstdc++-v3/include/Makefile.in +++ b/libstdc++-v3/include/Makefile.in @@ -398,6 +398,7 @@ bits_headers = \ ${bits_srcdir}/concept_check.h \ ${bits_srcdir}/cpp_type_traits.h \ ${bits_srcdir}/deque.tcc \ + ${bits_srcdir}/ebo_helper.h \ ${bits_srcdir}/enable_special_members.h \ ${bits_srcdir}/forward_list.h \ ${bits_srcdir}/forward_list.tcc \ diff --git a/libstdc++-v3/include/bits/ebo_helper.h b/libstdc++-v3/include/bits/ebo_helper.h new file mode 100644 index 0000000..5b9073a --- /dev/null +++ b/libstdc++-v3/include/bits/ebo_helper.h @@ -0,0 +1,114 @@ +// Ebo helper header -*- C++ -*- + +// Copyright (C) 2018 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/ebo_helper.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. + * @headername{unordered_map,unordered_set,memory} + */ + +#ifndef _EBO_HELPER_H +#define _EBO_HELPER_H 1 + +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +namespace __detail +{ + /** + * Primary class template _Ebo_helper. + * + * Helper class using EBO when it is not forbidden (the type is not + * final) and when it is worth it (the type is empty.) + */ + template + struct _Ebo_helper; + + /// Specialization using EBO. + template + struct _Ebo_helper<_Nm, _Tp, true> + : private _Tp + { + _Ebo_helper() = default; + _Ebo_helper(const _Tp& __tp) + : _Tp(__tp) + { } + + _Ebo_helper(_Tp&& __tp) + : _Tp(std::move(__tp)) + { } + + template + _Ebo_helper(_OtherTp&& __tp) + : _Tp(std::forward<_OtherTp>(__tp)) + { } + + static const _Tp& + _S_cget(const _Ebo_helper& __eboh) + { return __eboh; } + + static _Tp& + _S_get(_Ebo_helper& __eboh) + { return __eboh; } + }; + + /// Specialization not using EBO. + template + struct _Ebo_helper<_Nm, _Tp, false> + { + _Ebo_helper() = default; + _Ebo_helper(const _Tp& __tp) + : _M_tp(__tp) + { } + + _Ebo_helper(_Tp&& __tp) + : _M_tp(std::move(__tp)) + { } + + template + _Ebo_helper(_OtherTp&& __tp) + : _M_tp(std::forward<_OtherTp>(__tp)) + { } + + static const _Tp& + _S_cget(const _Ebo_helper& __eboh) + { return __eboh._M_tp; } + + static _Tp& + _S_get(_Ebo_helper& __eboh) + { return __eboh._M_tp; } + + private: + _Tp _M_tp; + }; +} + +_GLIBCXX_END_NAMESPACE_VERSION +} + +#endif diff --git a/libstdc++-v3/include/bits/hashtable_policy.h b/libstdc++-v3/include/bits/hashtable_policy.h index 3ff6b14..62f6fd1 100644 --- a/libstdc++-v3/include/bits/hashtable_policy.h +++ b/libstdc++-v3/include/bits/hashtable_policy.h @@ -34,6 +34,7 @@ #include // for std::tuple, std::forward_as_tuple #include // for std::uint_fast64_t #include // for std::min. +#include namespace std _GLIBCXX_VISIBILITY(default) { @@ -1088,59 +1089,8 @@ namespace __detail } }; - /** - * Primary class template _Hashtable_ebo_helper. - * - * Helper class using EBO when it is not forbidden (the type is not - * final) and when it is worth it (the type is empty.) - */ - template - struct _Hashtable_ebo_helper; - - /// Specialization using EBO. - template - struct _Hashtable_ebo_helper<_Nm, _Tp, true> - : private _Tp - { - _Hashtable_ebo_helper() = default; - - template - _Hashtable_ebo_helper(_OtherTp&& __tp) - : _Tp(std::forward<_OtherTp>(__tp)) - { } - - static const _Tp& - _S_cget(const _Hashtable_ebo_helper& __eboh) - { return static_cast(__eboh); } - - static _Tp& - _S_get(_Hashtable_ebo_helper& __eboh) - { return static_cast<_Tp&>(__eboh); } - }; - - /// Specialization not using EBO. template - struct _Hashtable_ebo_helper<_Nm, _Tp, false> - { - _Hashtable_ebo_helper() = default; - - template - _Hashtable_ebo_helper(_OtherTp&& __tp) - : _M_tp(std::forward<_OtherTp>(__tp)) - { } - - static const _Tp& - _S_cget(const _Hashtable_ebo_helper& __eboh) - { return __eboh._M_tp; } - - static _Tp& - _S_get(_Hashtable_ebo_helper& __eboh) - { return __eboh._M_tp; } - - private: - _Tp _M_tp; - }; + using _Hashtable_ebo_helper = _Ebo_helper<_Nm, _Tp>; /** * Primary class template _Local_iterator_base. diff --git a/libstdc++-v3/include/bits/shared_ptr_base.h b/libstdc++-v3/include/bits/shared_ptr_base.h index 870aeb9..191e4be 100644 --- a/libstdc++-v3/include/bits/shared_ptr_base.h +++ b/libstdc++-v3/include/bits/shared_ptr_base.h @@ -53,6 +53,7 @@ #include #include #include +#include #include namespace std _GLIBCXX_VISIBILITY(default) @@ -403,35 +404,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION inline void _Sp_counted_ptr::_M_dispose() noexcept { } - template - struct _Sp_ebo_helper; - - /// Specialization using EBO. - template - struct _Sp_ebo_helper<_Nm, _Tp, true> : private _Tp - { - explicit _Sp_ebo_helper(const _Tp& __tp) : _Tp(__tp) { } - explicit _Sp_ebo_helper(_Tp&& __tp) : _Tp(std::move(__tp)) { } - - static _Tp& - _S_get(_Sp_ebo_helper& __eboh) { return static_cast<_Tp&>(__eboh); } - }; - - /// Specialization not using EBO. template - struct _Sp_ebo_helper<_Nm, _Tp, false> - { - explicit _Sp_ebo_helper(const _Tp& __tp) : _M_tp(__tp) { } - explicit _Sp_ebo_helper(_Tp&& __tp) : _M_tp(std::move(__tp)) { } - - static _Tp& - _S_get(_Sp_ebo_helper& __eboh) - { return __eboh._M_tp; } - - private: - _Tp _M_tp; - }; + using _Sp_ebo_helper = __detail::_Ebo_helper<_Nm, _Tp>; // Support for custom deleter and/or allocator template --------------3127696E20F7895E81E793AB--