#pragma GCC system_header
-#include <string>
#include <bits/functexcept.h> // For invalid_argument, out_of_range,
// overflow_error
-#include <iosfwd>
-#include <bits/cxxabi_forced.h>
-
-#if __cplusplus >= 201103L
-# include <bits/functional_hash.h>
+#if _GLIBCXX_HOSTED
+# include <string>
+# include <iosfwd>
+# include <bits/cxxabi_forced.h>
+# if __cplusplus >= 201103L
+# include <bits/functional_hash.h>
+# endif
#endif
#define _GLIBCXX_BITSET_BITS_PER_WORD (__CHAR_BIT__ * __SIZEOF_LONG__)
{
_GLIBCXX_BEGIN_NAMESPACE_CONTAINER
+#if __cplusplus > 202002L && _GLIBCXX_HOSTED
+# define __cpp_lib_constexpr_bitset 202202L
+#endif
+
/**
* Base class, general case. It is a class invariant that _Nw will be
* nonnegative.
_S_maskbit(size_t __pos) _GLIBCXX_NOEXCEPT
{ return (static_cast<_WordT>(1)) << _S_whichbit(__pos); }
- _WordT&
+ _GLIBCXX14_CONSTEXPR _WordT&
_M_getword(size_t __pos) _GLIBCXX_NOEXCEPT
{ return _M_w[_S_whichword(__pos)]; }
{ return _M_w[_S_whichword(__pos)]; }
#if __cplusplus >= 201103L
- const _WordT*
+ constexpr const _WordT*
_M_getdata() const noexcept
{ return _M_w; }
#endif
- _WordT&
+ _GLIBCXX23_CONSTEXPR _WordT&
_M_hiword() _GLIBCXX_NOEXCEPT
{ return _M_w[_Nw - 1]; }
_M_hiword() const _GLIBCXX_NOEXCEPT
{ return _M_w[_Nw - 1]; }
- void
+ _GLIBCXX23_CONSTEXPR void
_M_do_and(const _Base_bitset<_Nw>& __x) _GLIBCXX_NOEXCEPT
{
for (size_t __i = 0; __i < _Nw; __i++)
_M_w[__i] &= __x._M_w[__i];
}
- void
+ _GLIBCXX14_CONSTEXPR void
_M_do_or(const _Base_bitset<_Nw>& __x) _GLIBCXX_NOEXCEPT
{
for (size_t __i = 0; __i < _Nw; __i++)
_M_w[__i] |= __x._M_w[__i];
}
- void
+ _GLIBCXX14_CONSTEXPR void
_M_do_xor(const _Base_bitset<_Nw>& __x) _GLIBCXX_NOEXCEPT
{
for (size_t __i = 0; __i < _Nw; __i++)
_M_w[__i] ^= __x._M_w[__i];
}
- void
+ _GLIBCXX14_CONSTEXPR void
_M_do_left_shift(size_t __shift) _GLIBCXX_NOEXCEPT;
- void
+ _GLIBCXX14_CONSTEXPR void
_M_do_right_shift(size_t __shift) _GLIBCXX_NOEXCEPT;
- void
+ _GLIBCXX14_CONSTEXPR void
_M_do_flip() _GLIBCXX_NOEXCEPT
{
for (size_t __i = 0; __i < _Nw; __i++)
_M_w[__i] = ~_M_w[__i];
}
- void
+ _GLIBCXX14_CONSTEXPR void
_M_do_set() _GLIBCXX_NOEXCEPT
{
for (size_t __i = 0; __i < _Nw; __i++)
_M_w[__i] = ~static_cast<_WordT>(0);
}
- void
+ _GLIBCXX14_CONSTEXPR void
_M_do_reset() _GLIBCXX_NOEXCEPT
- { __builtin_memset(_M_w, 0, _Nw * sizeof(_WordT)); }
+ {
+ if (__builtin_is_constant_evaluated())
+ {
+ for (_WordT& __w : _M_w)
+ __w = 0;
+ return;
+ }
- bool
+ __builtin_memset(_M_w, 0, _Nw * sizeof(_WordT));
+ }
+
+ _GLIBCXX14_CONSTEXPR bool
_M_is_equal(const _Base_bitset<_Nw>& __x) const _GLIBCXX_NOEXCEPT
{
for (size_t __i = 0; __i < _Nw; ++__i)
}
template<size_t _Nb>
- bool
+ _GLIBCXX14_CONSTEXPR bool
_M_are_all() const _GLIBCXX_NOEXCEPT
{
for (size_t __i = 0; __i < _Nw - 1; __i++)
- _Nb));
}
- bool
+ _GLIBCXX14_CONSTEXPR bool
_M_is_any() const _GLIBCXX_NOEXCEPT
{
for (size_t __i = 0; __i < _Nw; __i++)
return false;
}
- size_t
+ _GLIBCXX14_CONSTEXPR size_t
_M_do_count() const _GLIBCXX_NOEXCEPT
{
size_t __result = 0;
return __result;
}
- unsigned long
+ _GLIBCXX14_CONSTEXPR unsigned long
_M_do_to_ulong() const;
#if __cplusplus >= 201103L
- unsigned long long
+ _GLIBCXX14_CONSTEXPR unsigned long long
_M_do_to_ullong() const;
#endif
// find first "on" bit
- size_t
+ _GLIBCXX14_CONSTEXPR size_t
_M_do_find_first(size_t) const _GLIBCXX_NOEXCEPT;
// find the next "on" bit that follows "prev"
- size_t
+ _GLIBCXX14_CONSTEXPR size_t
_M_do_find_next(size_t, size_t) const _GLIBCXX_NOEXCEPT;
};
// Definitions of non-inline functions from _Base_bitset.
template<size_t _Nw>
- void
+ _GLIBCXX14_CONSTEXPR void
_Base_bitset<_Nw>::_M_do_left_shift(size_t __shift) _GLIBCXX_NOEXCEPT
{
if (__builtin_expect(__shift != 0, 1))
}
template<size_t _Nw>
- void
+ _GLIBCXX14_CONSTEXPR void
_Base_bitset<_Nw>::_M_do_right_shift(size_t __shift) _GLIBCXX_NOEXCEPT
{
if (__builtin_expect(__shift != 0, 1))
}
template<size_t _Nw>
- unsigned long
+ _GLIBCXX14_CONSTEXPR unsigned long
_Base_bitset<_Nw>::_M_do_to_ulong() const
{
for (size_t __i = 1; __i < _Nw; ++__i)
#if __cplusplus >= 201103L
template<size_t _Nw>
- unsigned long long
+ _GLIBCXX14_CONSTEXPR unsigned long long
_Base_bitset<_Nw>::_M_do_to_ullong() const
{
const bool __dw = sizeof(unsigned long long) > sizeof(unsigned long);
#endif
template<size_t _Nw>
- size_t
+ _GLIBCXX14_CONSTEXPR size_t
_Base_bitset<_Nw>::
_M_do_find_first(size_t __not_found) const _GLIBCXX_NOEXCEPT
{
}
template<size_t _Nw>
- size_t
+ _GLIBCXX14_CONSTEXPR size_t
_Base_bitset<_Nw>::
_M_do_find_next(size_t __prev, size_t __not_found) const _GLIBCXX_NOEXCEPT
{
_S_maskbit(size_t __pos) _GLIBCXX_NOEXCEPT
{ return (static_cast<_WordT>(1)) << _S_whichbit(__pos); }
- _WordT&
+ _GLIBCXX14_CONSTEXPR _WordT&
_M_getword(size_t) _GLIBCXX_NOEXCEPT
{ return _M_w; }
{ return _M_w; }
#if __cplusplus >= 201103L
- const _WordT*
+ constexpr const _WordT*
_M_getdata() const noexcept
{ return &_M_w; }
#endif
- _WordT&
+ _GLIBCXX14_CONSTEXPR _WordT&
_M_hiword() _GLIBCXX_NOEXCEPT
{ return _M_w; }
_M_hiword() const _GLIBCXX_NOEXCEPT
{ return _M_w; }
- void
+ _GLIBCXX14_CONSTEXPR void
_M_do_and(const _Base_bitset<1>& __x) _GLIBCXX_NOEXCEPT
{ _M_w &= __x._M_w; }
- void
+ _GLIBCXX14_CONSTEXPR void
_M_do_or(const _Base_bitset<1>& __x) _GLIBCXX_NOEXCEPT
{ _M_w |= __x._M_w; }
- void
+ _GLIBCXX14_CONSTEXPR void
_M_do_xor(const _Base_bitset<1>& __x) _GLIBCXX_NOEXCEPT
{ _M_w ^= __x._M_w; }
- void
+ _GLIBCXX14_CONSTEXPR void
_M_do_left_shift(size_t __shift) _GLIBCXX_NOEXCEPT
{ _M_w <<= __shift; }
- void
+ _GLIBCXX14_CONSTEXPR void
_M_do_right_shift(size_t __shift) _GLIBCXX_NOEXCEPT
{ _M_w >>= __shift; }
- void
+ _GLIBCXX14_CONSTEXPR void
_M_do_flip() _GLIBCXX_NOEXCEPT
{ _M_w = ~_M_w; }
- void
+ _GLIBCXX14_CONSTEXPR void
_M_do_set() _GLIBCXX_NOEXCEPT
{ _M_w = ~static_cast<_WordT>(0); }
- void
+ _GLIBCXX14_CONSTEXPR void
_M_do_reset() _GLIBCXX_NOEXCEPT
{ _M_w = 0; }
- bool
+ _GLIBCXX14_CONSTEXPR bool
_M_is_equal(const _Base_bitset<1>& __x) const _GLIBCXX_NOEXCEPT
{ return _M_w == __x._M_w; }
template<size_t _Nb>
- bool
+ _GLIBCXX14_CONSTEXPR bool
_M_are_all() const _GLIBCXX_NOEXCEPT
{ return _M_w == (~static_cast<_WordT>(0)
>> (_GLIBCXX_BITSET_BITS_PER_WORD - _Nb)); }
- bool
+ _GLIBCXX14_CONSTEXPR bool
_M_is_any() const _GLIBCXX_NOEXCEPT
{ return _M_w != 0; }
- size_t
+ _GLIBCXX14_CONSTEXPR size_t
_M_do_count() const _GLIBCXX_NOEXCEPT
{ return __builtin_popcountl(_M_w); }
- unsigned long
+ _GLIBCXX14_CONSTEXPR unsigned long
_M_do_to_ulong() const _GLIBCXX_NOEXCEPT
{ return _M_w; }
#if __cplusplus >= 201103L
- unsigned long long
+ constexpr unsigned long long
_M_do_to_ullong() const noexcept
{ return _M_w; }
#endif
- size_t
+ _GLIBCXX14_CONSTEXPR size_t
_M_do_find_first(size_t __not_found) const _GLIBCXX_NOEXCEPT
{
if (_M_w != 0)
}
// find the next "on" bit that follows "prev"
- size_t
+ _GLIBCXX14_CONSTEXPR size_t
_M_do_find_next(size_t __prev, size_t __not_found) const
_GLIBCXX_NOEXCEPT
{
// This would normally give access to the data. The bounds-checking
// in the bitset class will prevent the user from getting this far,
- // but (1) it must still return an lvalue to compile, and (2) the
- // user might call _Unchecked_set directly, in which case this /needs/
- // to fail. Let's not penalize zero-length users unless they actually
+ // but this must fail if the user calls _Unchecked_set directly.
+ // Let's not penalize zero-length users unless they actually
// make an unchecked call; all the memory ugliness is therefore
// localized to this single should-never-get-this-far function.
+ __attribute__((__noreturn__))
_WordT&
_M_getword(size_t) _GLIBCXX_NOEXCEPT
- {
- __throw_out_of_range(__N("_Base_bitset::_M_getword"));
- return *new _WordT;
- }
+ { __throw_out_of_range(__N("_Base_bitset::_M_getword")); }
_GLIBCXX_CONSTEXPR _WordT
_M_getword(size_t) const _GLIBCXX_NOEXCEPT
_M_hiword() const _GLIBCXX_NOEXCEPT
{ return 0; }
- void
+ _GLIBCXX14_CONSTEXPR void
_M_do_and(const _Base_bitset<0>&) _GLIBCXX_NOEXCEPT
{ }
- void
+ _GLIBCXX14_CONSTEXPR void
_M_do_or(const _Base_bitset<0>&) _GLIBCXX_NOEXCEPT
{ }
- void
+ _GLIBCXX14_CONSTEXPR void
_M_do_xor(const _Base_bitset<0>&) _GLIBCXX_NOEXCEPT
{ }
- void
+ _GLIBCXX14_CONSTEXPR void
_M_do_left_shift(size_t) _GLIBCXX_NOEXCEPT
{ }
- void
+ _GLIBCXX14_CONSTEXPR void
_M_do_right_shift(size_t) _GLIBCXX_NOEXCEPT
{ }
- void
+ _GLIBCXX14_CONSTEXPR void
_M_do_flip() _GLIBCXX_NOEXCEPT
{ }
- void
+ _GLIBCXX14_CONSTEXPR void
_M_do_set() _GLIBCXX_NOEXCEPT
{ }
- void
+ _GLIBCXX14_CONSTEXPR void
_M_do_reset() _GLIBCXX_NOEXCEPT
{ }
// Are all empty bitsets equal to each other? Are they equal to
// themselves? How to compare a thing which has no state? What is
// the sound of one zero-length bitset clapping?
- bool
+ _GLIBCXX_CONSTEXPR bool
_M_is_equal(const _Base_bitset<0>&) const _GLIBCXX_NOEXCEPT
{ return true; }
template<size_t _Nb>
- bool
+ _GLIBCXX_CONSTEXPR bool
_M_are_all() const _GLIBCXX_NOEXCEPT
{ return true; }
- bool
+ _GLIBCXX_CONSTEXPR bool
_M_is_any() const _GLIBCXX_NOEXCEPT
{ return false; }
- size_t
+ _GLIBCXX_CONSTEXPR size_t
_M_do_count() const _GLIBCXX_NOEXCEPT
{ return 0; }
- unsigned long
+ _GLIBCXX_CONSTEXPR unsigned long
_M_do_to_ulong() const _GLIBCXX_NOEXCEPT
{ return 0; }
#if __cplusplus >= 201103L
- unsigned long long
+ constexpr unsigned long long
_M_do_to_ullong() const noexcept
{ return 0; }
#endif
// Normally "not found" is the size, but that could also be
// misinterpreted as an index in this corner case. Oh well.
- size_t
+ _GLIBCXX_CONSTEXPR size_t
_M_do_find_first(size_t) const _GLIBCXX_NOEXCEPT
{ return 0; }
- size_t
+ _GLIBCXX_CONSTEXPR size_t
_M_do_find_next(size_t, size_t) const _GLIBCXX_NOEXCEPT
{ return 0; }
};
{
typedef unsigned long _WordT;
- static void
+ static _GLIBCXX14_CONSTEXPR void
_S_do_sanitize(_WordT& __val) _GLIBCXX_NOEXCEPT
{ __val &= ~((~static_cast<_WordT>(0)) << _Extrabits); }
};
{
typedef unsigned long _WordT;
- static void
+ static _GLIBCXX14_CONSTEXPR void
_S_do_sanitize(_WordT) _GLIBCXX_NOEXCEPT { }
};
typedef _Base_bitset<_GLIBCXX_BITSET_WORDS(_Nb)> _Base;
typedef unsigned long _WordT;
+#if _GLIBCXX_HOSTED
template<class _CharT, class _Traits, class _Alloc>
+ _GLIBCXX23_CONSTEXPR
void
_M_check_initial_position(const std::basic_string<_CharT, _Traits, _Alloc>& __s,
size_t __position) const
"(which is %zu)"),
__position, __s.size());
}
+#endif // HOSTED
+ _GLIBCXX23_CONSTEXPR
void _M_check(size_t __position, const char *__s) const
{
if (__position >= _Nb)
__s, __position, _Nb);
}
+ _GLIBCXX23_CONSTEXPR
void
_M_do_sanitize() _GLIBCXX_NOEXCEPT
{
reference();
public:
+ _GLIBCXX23_CONSTEXPR
reference(bitset& __b, size_t __pos) _GLIBCXX_NOEXCEPT
{
_M_wp = &__b._M_getword(__pos);
reference(const reference&) = default;
#endif
+#if __cplusplus > 202002L && __cpp_constexpr_dynamic_alloc
+ constexpr
+#endif
~reference() _GLIBCXX_NOEXCEPT
{ }
// For b[i] = __x;
+ _GLIBCXX23_CONSTEXPR
reference&
operator=(bool __x) _GLIBCXX_NOEXCEPT
{
}
// For b[i] = b[__j];
+ _GLIBCXX23_CONSTEXPR
reference&
operator=(const reference& __j) _GLIBCXX_NOEXCEPT
{
}
// Flips the bit
+ _GLIBCXX23_CONSTEXPR
bool
operator~() const _GLIBCXX_NOEXCEPT
{ return (*(_M_wp) & _Base::_S_maskbit(_M_bpos)) == 0; }
// For __x = b[i];
+ _GLIBCXX23_CONSTEXPR
operator bool() const _GLIBCXX_NOEXCEPT
{ return (*(_M_wp) & _Base::_S_maskbit(_M_bpos)) != 0; }
// For b[i].flip();
+ _GLIBCXX23_CONSTEXPR
reference&
flip() _GLIBCXX_NOEXCEPT
{
{ _M_do_sanitize(); }
#endif
+#if _GLIBCXX_HOSTED
/**
* Use a subset of a string.
* @param __s A string of @a 0 and @a 1 characters.
* which is neither @a 0 nor @a 1.
*/
template<class _CharT, class _Traits, class _Alloc>
+ _GLIBCXX23_CONSTEXPR
explicit
bitset(const std::basic_string<_CharT, _Traits, _Alloc>& __s,
size_t __position = 0)
* which is neither @a 0 nor @a 1.
*/
template<class _CharT, class _Traits, class _Alloc>
+ _GLIBCXX23_CONSTEXPR
bitset(const std::basic_string<_CharT, _Traits, _Alloc>& __s,
size_t __position, size_t __n)
: _Base()
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 396. what are characters zero and one.
template<class _CharT, class _Traits, class _Alloc>
+ _GLIBCXX23_CONSTEXPR
bitset(const std::basic_string<_CharT, _Traits, _Alloc>& __s,
size_t __position, size_t __n,
_CharT __zero, _CharT __one = _CharT('1'))
* which is neither @a __zero nor @a __one.
*/
template<typename _CharT>
+ [[__gnu__::__nonnull__]]
+ _GLIBCXX23_CONSTEXPR
explicit
bitset(const _CharT* __str,
typename std::basic_string<_CharT>::size_type __n
__n, __zero,
__one);
}
-#endif
+#endif // C++11
+#endif // HOSTED
// 23.3.5.2 bitset operations:
///@{
*
* These should be self-explanatory.
*/
+ _GLIBCXX23_CONSTEXPR
bitset<_Nb>&
operator&=(const bitset<_Nb>& __rhs) _GLIBCXX_NOEXCEPT
{
return *this;
}
+ _GLIBCXX23_CONSTEXPR
bitset<_Nb>&
operator|=(const bitset<_Nb>& __rhs) _GLIBCXX_NOEXCEPT
{
return *this;
}
+ _GLIBCXX23_CONSTEXPR
bitset<_Nb>&
operator^=(const bitset<_Nb>& __rhs) _GLIBCXX_NOEXCEPT
{
*
* These should be self-explanatory.
*/
+ _GLIBCXX23_CONSTEXPR
bitset<_Nb>&
operator<<=(size_t __position) _GLIBCXX_NOEXCEPT
{
return *this;
}
+ _GLIBCXX23_CONSTEXPR
bitset<_Nb>&
operator>>=(size_t __position) _GLIBCXX_NOEXCEPT
{
* extensions from the SGI version. They do no range checking.
* @ingroup SGIextensions
*/
+ _GLIBCXX23_CONSTEXPR
bitset<_Nb>&
_Unchecked_set(size_t __pos) _GLIBCXX_NOEXCEPT
{
return *this;
}
+ _GLIBCXX23_CONSTEXPR
bitset<_Nb>&
_Unchecked_set(size_t __pos, int __val) _GLIBCXX_NOEXCEPT
{
return *this;
}
+ _GLIBCXX23_CONSTEXPR
bitset<_Nb>&
_Unchecked_reset(size_t __pos) _GLIBCXX_NOEXCEPT
{
return *this;
}
+ _GLIBCXX23_CONSTEXPR
bitset<_Nb>&
_Unchecked_flip(size_t __pos) _GLIBCXX_NOEXCEPT
{
/**
* @brief Sets every bit to true.
*/
+ _GLIBCXX23_CONSTEXPR
bitset<_Nb>&
set() _GLIBCXX_NOEXCEPT
{
* @param __val Either true or false, defaults to true.
* @throw std::out_of_range If @a pos is bigger the size of the %set.
*/
+ _GLIBCXX23_CONSTEXPR
bitset<_Nb>&
set(size_t __position, bool __val = true)
{
/**
* @brief Sets every bit to false.
*/
+ _GLIBCXX23_CONSTEXPR
bitset<_Nb>&
reset() _GLIBCXX_NOEXCEPT
{
*
* Same as writing @c set(pos,false).
*/
+ _GLIBCXX23_CONSTEXPR
bitset<_Nb>&
reset(size_t __position)
{
/**
* @brief Toggles every bit to its opposite value.
*/
+ _GLIBCXX23_CONSTEXPR
bitset<_Nb>&
flip() _GLIBCXX_NOEXCEPT
{
* @param __position The index of the bit.
* @throw std::out_of_range If @a pos is bigger the size of the %set.
*/
+ _GLIBCXX23_CONSTEXPR
bitset<_Nb>&
flip(size_t __position)
{
}
/// See the no-argument flip().
+ _GLIBCXX23_CONSTEXPR
bitset<_Nb>
operator~() const _GLIBCXX_NOEXCEPT
{ return bitset<_Nb>(*this).flip(); }
* The DR has since been changed: range-checking is a precondition
* (users' responsibility), and these functions must not throw. -pme
*/
+ _GLIBCXX23_CONSTEXPR
reference
operator[](size_t __position)
{ return reference(*this, __position); }
* @throw std::overflow_error If there are too many bits to be
* represented in an @c unsigned @c long.
*/
+ _GLIBCXX23_CONSTEXPR
unsigned long
to_ulong() const
{ return this->_M_do_to_ulong(); }
#if __cplusplus >= 201103L
+ _GLIBCXX23_CONSTEXPR
unsigned long long
to_ullong() const
{ return this->_M_do_to_ullong(); }
#endif
+#if _GLIBCXX_HOSTED
/**
* @brief Returns a character interpretation of the %bitset.
* @return The string equivalent of the bits.
* an example).
*/
template<class _CharT, class _Traits, class _Alloc>
+ _GLIBCXX23_CONSTEXPR
std::basic_string<_CharT, _Traits, _Alloc>
to_string() const
{
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 396. what are characters zero and one.
template<class _CharT, class _Traits, class _Alloc>
+ _GLIBCXX23_CONSTEXPR
std::basic_string<_CharT, _Traits, _Alloc>
to_string(_CharT __zero, _CharT __one = _CharT('1')) const
{
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 434. bitset::to_string() hard to use.
template<class _CharT, class _Traits>
+ _GLIBCXX23_CONSTEXPR
std::basic_string<_CharT, _Traits, std::allocator<_CharT> >
to_string() const
{ return to_string<_CharT, _Traits, std::allocator<_CharT> >(); }
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 853. to_string needs updating with zero and one.
template<class _CharT, class _Traits>
+ _GLIBCXX23_CONSTEXPR
std::basic_string<_CharT, _Traits, std::allocator<_CharT> >
to_string(_CharT __zero, _CharT __one = _CharT('1')) const
{ return to_string<_CharT, _Traits,
std::allocator<_CharT> >(__zero, __one); }
template<class _CharT>
+ _GLIBCXX23_CONSTEXPR
std::basic_string<_CharT, std::char_traits<_CharT>,
std::allocator<_CharT> >
to_string() const
}
template<class _CharT>
+ _GLIBCXX23_CONSTEXPR
std::basic_string<_CharT, std::char_traits<_CharT>,
std::allocator<_CharT> >
to_string(_CharT __zero, _CharT __one = _CharT('1')) const
std::allocator<_CharT> >(__zero, __one);
}
+ _GLIBCXX23_CONSTEXPR
std::basic_string<char, std::char_traits<char>, std::allocator<char> >
to_string() const
{
std::allocator<char> >();
}
+ _GLIBCXX23_CONSTEXPR
std::basic_string<char, std::char_traits<char>, std::allocator<char> >
to_string(char __zero, char __one = '1') const
{
// Helper functions for string operations.
template<class _CharT, class _Traits>
+ _GLIBCXX23_CONSTEXPR
void
_M_copy_from_ptr(const _CharT*, size_t, size_t, size_t,
_CharT, _CharT);
template<class _CharT, class _Traits, class _Alloc>
+ _GLIBCXX23_CONSTEXPR
void
_M_copy_from_string(const std::basic_string<_CharT,
_Traits, _Alloc>& __s, size_t __pos, size_t __n,
__zero, __one); }
template<class _CharT, class _Traits, class _Alloc>
+ _GLIBCXX23_CONSTEXPR
void
_M_copy_to_string(std::basic_string<_CharT, _Traits, _Alloc>&,
_CharT, _CharT) const;
// NB: Backward compat.
template<class _CharT, class _Traits, class _Alloc>
+ _GLIBCXX23_CONSTEXPR
void
_M_copy_from_string(const std::basic_string<_CharT,
_Traits, _Alloc>& __s, size_t __pos, size_t __n)
{ _M_copy_from_string(__s, __pos, __n, _CharT('0'), _CharT('1')); }
template<class _CharT, class _Traits, class _Alloc>
+ _GLIBCXX23_CONSTEXPR
void
_M_copy_to_string(std::basic_string<_CharT, _Traits,_Alloc>& __s) const
{ _M_copy_to_string(__s, _CharT('0'), _CharT('1')); }
+#endif // HOSTED
/// Returns the number of bits which are set.
+ _GLIBCXX23_CONSTEXPR
size_t
count() const _GLIBCXX_NOEXCEPT
{ return this->_M_do_count(); }
///@{
/// These comparisons for equality/inequality are, well, @e bitwise.
+ _GLIBCXX23_CONSTEXPR
bool
operator==(const bitset<_Nb>& __rhs) const _GLIBCXX_NOEXCEPT
{ return this->_M_is_equal(__rhs); }
#if __cpp_impl_three_way_comparison < 201907L
+ _GLIBCXX23_CONSTEXPR
bool
operator!=(const bitset<_Nb>& __rhs) const _GLIBCXX_NOEXCEPT
{ return !this->_M_is_equal(__rhs); }
* @return The value at @a pos.
* @throw std::out_of_range If @a pos is bigger the size of the %set.
*/
+ _GLIBCXX23_CONSTEXPR
bool
test(size_t __position) const
{
* @brief Tests whether all the bits are on.
* @return True if all the bits are set.
*/
+ _GLIBCXX23_CONSTEXPR
bool
all() const _GLIBCXX_NOEXCEPT
{ return this->template _M_are_all<_Nb>(); }
* @brief Tests whether any of the bits are on.
* @return True if at least one bit is set.
*/
+ _GLIBCXX23_CONSTEXPR
bool
any() const _GLIBCXX_NOEXCEPT
{ return this->_M_is_any(); }
* @brief Tests whether any of the bits are on.
* @return True if none of the bits are set.
*/
+ _GLIBCXX23_CONSTEXPR
bool
none() const _GLIBCXX_NOEXCEPT
{ return !this->_M_is_any(); }
///@{
/// Self-explanatory.
+ _GLIBCXX23_CONSTEXPR
bitset<_Nb>
operator<<(size_t __position) const _GLIBCXX_NOEXCEPT
{ return bitset<_Nb>(*this) <<= __position; }
+ _GLIBCXX23_CONSTEXPR
bitset<_Nb>
operator>>(size_t __position) const _GLIBCXX_NOEXCEPT
{ return bitset<_Nb>(*this) >>= __position; }
* @ingroup SGIextensions
* @sa _Find_next
*/
+ _GLIBCXX23_CONSTEXPR
size_t
_Find_first() const _GLIBCXX_NOEXCEPT
{ return this->_M_do_find_first(_Nb); }
* @ingroup SGIextensions
* @sa _Find_first
*/
+ _GLIBCXX23_CONSTEXPR
size_t
_Find_next(size_t __prev) const _GLIBCXX_NOEXCEPT
{ return this->_M_do_find_next(__prev, _Nb); }
};
+#if _GLIBCXX_HOSTED
// Definitions of non-inline member functions.
template<size_t _Nb>
template<class _CharT, class _Traits>
+ _GLIBCXX23_CONSTEXPR
void
bitset<_Nb>::
_M_copy_from_ptr(const _CharT* __s, size_t __len,
template<size_t _Nb>
template<class _CharT, class _Traits, class _Alloc>
+ _GLIBCXX23_CONSTEXPR
void
bitset<_Nb>::
_M_copy_to_string(std::basic_string<_CharT, _Traits, _Alloc>& __s,
if (_Unchecked_test(__i - 1))
_Traits::assign(__s[_Nb - __i], __one);
}
+#endif // HOSTED
// 23.3.5.3 bitset operations:
///@{
* These should be self-explanatory.
*/
template<size_t _Nb>
+ _GLIBCXX23_CONSTEXPR
inline bitset<_Nb>
operator&(const bitset<_Nb>& __x, const bitset<_Nb>& __y) _GLIBCXX_NOEXCEPT
{
}
template<size_t _Nb>
+ _GLIBCXX23_CONSTEXPR
inline bitset<_Nb>
operator|(const bitset<_Nb>& __x, const bitset<_Nb>& __y) _GLIBCXX_NOEXCEPT
{
}
template <size_t _Nb>
+ _GLIBCXX23_CONSTEXPR
inline bitset<_Nb>
operator^(const bitset<_Nb>& __x, const bitset<_Nb>& __y) _GLIBCXX_NOEXCEPT
{
}
///@}
+#if _GLIBCXX_HOSTED
///@{
/**
* @brief Global I/O operators for bitsets.
return __os << __tmp;
}
///@}
+#endif // HOSTED
_GLIBCXX_END_NAMESPACE_CONTAINER
} // namespace std
#undef _GLIBCXX_BITSET_BITS_PER_WORD
#undef _GLIBCXX_BITSET_BITS_PER_ULL
-#if __cplusplus >= 201103L
+#if __cplusplus >= 201103L && _GLIBCXX_HOSTED
namespace std _GLIBCXX_VISIBILITY(default)
{
#endif // C++11
-#ifdef _GLIBCXX_DEBUG
+#ifdef _GLIBCXX_DEBUG && _GLIBCXX_HOSTED
# include <debug/bitset>
#endif