As pointed out in the PR we already do this for reset().
libstdc++-v3/ChangeLog:
PR libstdc++/113807
* include/std/bitset (bitset::set()): Use memset instead of a
loop over the individual words.
_GLIBCXX14_CONSTEXPR void
_M_do_set() _GLIBCXX_NOEXCEPT
{
- for (size_t __i = 0; __i < _Nw; __i++)
- _M_w[__i] = ~static_cast<_WordT>(0);
+#if __cplusplus >= 201402L
+ if (__builtin_is_constant_evaluated())
+ {
+ for (_WordT& __w : _M_w)
+ __w = ~static_cast<_WordT>(0);;
+ return;
+ }
+#endif
+ __builtin_memset(_M_w, 0xFF, _Nw * sizeof(_WordT));
}
_GLIBCXX14_CONSTEXPR void