From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2181) id 1FB1B385BF86; Tue, 30 Nov 2021 20:11:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1FB1B385BF86 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jonathan Wakely To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r12-5637] libstdc++: Skip tag dispatching for _S_relocate in C++17 X-Act-Checkin: gcc X-Git-Author: Jonathan Wakely X-Git-Refname: refs/heads/master X-Git-Oldrev: cca6090b13ab503bef1cfa327e2d107789d6bd30 X-Git-Newrev: 91c26004037db689954318d3d1c801eea18d45f4 Message-Id: <20211130201122.1FB1B385BF86@sourceware.org> Date: Tue, 30 Nov 2021 20:11:22 +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: Tue, 30 Nov 2021 20:11:22 -0000 https://gcc.gnu.org/g:91c26004037db689954318d3d1c801eea18d45f4 commit r12-5637-g91c26004037db689954318d3d1c801eea18d45f4 Author: Jonathan Wakely Date: Tue Nov 30 13:41:32 2021 +0000 libstdc++: Skip tag dispatching for _S_relocate in C++17 In C++17 mode all callers of _S_relocate have already done: if constexpr (_S_use_relocate()) so we don't need to repeat that check and use tag dispatching to avoid ill-formed instantiations. libstdc++-v3/ChangeLog: * include/bits/stl_vector.h (vector::_S_do_relocate): Remove C++20 constexpr specifier. (vector::_S_relocate) [__cpp_if_constexpr]: Call __relocate_a directly without tag dispatching. Diff: --- libstdc++-v3/include/bits/stl_vector.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/libstdc++-v3/include/bits/stl_vector.h b/libstdc++-v3/include/bits/stl_vector.h index 4587757637e..36b2cff3d78 100644 --- a/libstdc++-v3/include/bits/stl_vector.h +++ b/libstdc++-v3/include/bits/stl_vector.h @@ -481,14 +481,14 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER return _S_nothrow_relocate(__is_move_insertable<_Tp_alloc_type>{}); } - static _GLIBCXX20_CONSTEXPR pointer + static pointer _S_do_relocate(pointer __first, pointer __last, pointer __result, _Tp_alloc_type& __alloc, true_type) noexcept { return std::__relocate_a(__first, __last, __result, __alloc); } - static _GLIBCXX20_CONSTEXPR pointer + static pointer _S_do_relocate(pointer, pointer, pointer __result, _Tp_alloc_type&, false_type) noexcept { return __result; } @@ -497,8 +497,13 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER _S_relocate(pointer __first, pointer __last, pointer __result, _Tp_alloc_type& __alloc) noexcept { +#if __cpp_if_constexpr + // All callers have already checked _S_use_relocate() so just do it. + return std::__relocate_a(__first, __last, __result, __alloc); +#else using __do_it = __bool_constant<_S_use_relocate()>; return _S_do_relocate(__first, __last, __result, __alloc, __do_it{}); +#endif } #endif // C++11