On Tue, 8 Jul 2025 at 08:20, Jonathan Wakely <jwakely....@gmail.com> wrote: > > > > On Tue, 8 Jul 2025, 08:04 Tomasz Kaminski, <tkami...@redhat.com> wrote: >> >> LGTM. Thanks. >> >> On Mon, Jul 7, 2025 at 11:09 PM Nathan Myers <n...@cantrip.org> wrote: >>> >>> This adds the new bitset constructor from string_view >>> defined in P2697 to the debug version of the type. >>> >>> libstdc++-v3/Changelog: >>> PR libstdc++/119742 >>> * include/debug/bitset: Add new ctor. >>> --- >>> libstdc++-v3/include/debug/bitset | 12 ++++++++++++ >>> 1 file changed, 12 insertions(+) >>> >>> diff --git a/libstdc++-v3/include/debug/bitset >>> b/libstdc++-v3/include/debug/bitset >>> index ad9b7b5c4b0..43656a4efd3 100644 >>> --- a/libstdc++-v3/include/debug/bitset >>> +++ b/libstdc++-v3/include/debug/bitset >>> @@ -164,6 +164,18 @@ namespace __debug >>> _CharT __zero, _CharT __one = _CharT('1')) >>> : _Base(__str, __pos, __n, __zero, __one) { } >>> >>> +#ifdef __cpp_lib_bitset // ... from string_view >>> + template<class _CharT, class _Traits> >>> + constexpr explicit >>> + bitset(std::basic_string_view<_CharT, _Traits> __s, >>> + std::basic_string_view<_CharT, _Traits>::size_type __position = 0, >>> + std::basic_string_view<_CharT, _Traits>::size_type __n = >>> + std::basic_string_view<_CharT, _Traits>::npos, >>> + _CharT __zero = _CharT('0'), _CharT __one = _CharT('1')) >>> + : _Base(__s.data() + std::min(__position, __s.size()), >>> + std::min(__n, __s.size()), __zero, __one) { } >>> +#endif > > > The base class needs to repeat those length checks anyway, so is there a > reason to do the std::min calls here rather than just pass the arguments to > the base unchanged?
Ping I'd prefer if this constructor just forwarded its params unchanged to the base class, and let it do what it needs to do. > > >>> + >>> _GLIBCXX23_CONSTEXPR >>> bitset(const _Base& __x) : _Base(__x) { } >>> >>> -- >>> 2.50.0 >>>