Jonathan Wakely [Wednesday, 1 July 2026, 12:55:41 CEST]:
> On Wed, 03 Jun 2026 at 05:42 +0000, Matthias Kretz via Sourceware Forge
wrote:
> >+ template <typename _T0, typename _T1>
> >+ constexpr void
> >+ __check_hi_bits_for_zero(const __trivial_pair<_T0, _T1>& __p)
> >+ {
> >+ __check_hi_bits_for_zero(__p._M_first);
> >+ __check_hi_bits_for_zero(__p._M_second);
>
> Do we care about qualifying these to suppress ADL?
std::simd::__check_hi_bits_for_zero? 🤷 I can't imagine how ADL could turn this
into a problem. All involved types are either standard integral types or
std::simd::__trivial_pair.
Would full qualification be cheaper to compile (in theory)?
If I do, also qualifying __unwrap_pairs_to_ullong, __unwrap_pairs_to_bitset,
and __bitset_to_pairs would be consistent:
> >+ }
> >+
> >+ constexpr unsigned long long
> >+ __unwrap_pairs_to_ullong(unsigned_integral auto __x)
> >+ { return __x; }
> >+
> >+ template <typename _T0, typename _T1>
> >+ constexpr unsigned long long
> >+ __unwrap_pairs_to_ullong(const __trivial_pair<_T0, _T1>& __p)
> >+ {
> >+ __check_hi_bits_for_zero(__p._M_second);
> >+ return __unwrap_pairs_to_ullong(__p._M_first);
> >+ }
> >+
> >+ template <int _Np>
> >+ constexpr bitset<_Np>
> >+ __unwrap_pairs_to_bitset(unsigned_integral auto __x)
> >+ {
> >+ static_assert(_Np <= 64);
> >+ return __x;
> >+ }
> >+
> >+ template <size_t _Np, typename _T0, typename _T1>
> >+ constexpr bitset<_Np>
> >+ __unwrap_pairs_to_bitset(const __trivial_pair<_T0, _T1>& __p)
> >+ {
> >+ constexpr size_t _N0 = __bit_floor(_Np);
> >+ constexpr size_t _N1 = _Np - _N0;
> >+ static_assert(_N0 % 64 == 0);
> >+ struct _Tmp
> >+ {
> >+ bitset<__bit_floor(_Np)> _M_lo;
> >+ bitset<_Np - __bit_floor(_Np)> _M_hi;
> >+ };
> >+ _Tmp __tmp = {__unwrap_pairs_to_bitset<_N0>(__p._M_first),
> >+ __unwrap_pairs_to_bitset<_N1>(__p._M_second)};
> >+ return __builtin_bit_cast(bitset<_Np>, __tmp);
> >+ }
> >+
> >+ template <size_t _Bytes>
> >+ consteval auto
> >+ __tree_of_ulong()
> >+ {
> >+ static constexpr size_t _N0 = __bit_floor(_Bytes - 1);
> >+ static constexpr size_t _N1 = _Bytes - _N0;
> >+ if constexpr (_Bytes <= sizeof(unsigned long))
> >+ return 0ul;
> >+ else
> >+ return __trivial_pair {__tree_of_ulong<_N0>(),
__tree_of_ulong<_N1>()};
> >+ }
> >+
> >+ template <size_t _Bytes>
> >+ using __tree_of_ulong_t = decltype(__tree_of_ulong<_Bytes>());
> >+
> >+ template <size_t _Np>
> >+ constexpr auto
> >+ __bitset_to_pairs(const bitset<_Np>& __b) noexcept
> >+ {
> >+ if constexpr (_Np <= 64)
> >+ return __b.to_ullong();
> >+ else
> >+ return __builtin_bit_cast(__tree_of_ulong_t<__div_ceil(_Np,
> >size_t(__CHAR_BIT__))>, __b); + }
--
──────────────────────────────────────────────────────────────────────────
Dr. Matthias Kretz https://mattkretz.github.io
GSI Helmholtz Center for Heavy Ion Research https://gsi.de
std::simd
──────────────────────────────────────────────────────────────────────────