32#if 8 == _RWSTD_CHAR_BIT
33# define _RWSTD_LOG2_CHAR_BITS 3
34#elif 16 == _RWSTD_CHAR_BIT
35# define _RWSTD_LOG2_CHAR_BITS 4
36#elif 32 == _RWSTD_CHAR_BIT
37# define _RWSTD_LOG2_CHAR_BITS 5
38#elif 64 == _RWSTD_CHAR_BIT
39# define _RWSTD_LOG2_CHAR_BITS 6
42#if 1 == _RWSTD_LONG_SIZE
43# define _RWSTD_LOG2_LONG_SIZE 0
44#elif 2 == _RWSTD_LONG_SIZE
45# define _RWSTD_LOG2_LONG_SIZE 1
46#elif 4 == _RWSTD_LONG_SIZE
47# define _RWSTD_LOG2_LONG_SIZE 2
48#elif 8 == _RWSTD_LONG_SIZE
49# define _RWSTD_LOG2_LONG_SIZE 3
50#elif 16 == _RWSTD_LONG_SIZE
51# define _RWSTD_LOG2_LONG_SIZE 4
56template <
class _CharT,
class _Traits>
57void __rw_bitset (
unsigned long *__bits, _RWSTD_SIZE_T __maxbits,
58 const _CharT *__str, _RWSTD_SIZE_T __slen,
59 const _Traits*, _CharT __b0, _CharT __b1,
60 _RWSTD_SIZE_T __pos, _RWSTD_SIZE_T __n,
61 const char *__file,
const char *__fun)
63 const _RWSTD_SIZE_T __wordbits =
sizeof *__bits * _RWSTD_CHAR_BIT;
65 if (_RWSTD_SIZE_MAX == __slen)
66 __slen = _Traits::length (__str);
75 const _RWSTD_SIZE_T __nchars =
76 __n < (__slen - __pos) ? __n : __slen - __pos;
79 const _RWSTD_SIZE_T __nbits = __nchars < __maxbits ? __nchars : __maxbits;
84#if defined (_RWSTD_LOG2_CHAR_BITS) && defined (_RWSTD_LOG2_LONG_SIZE)
86 const _RWSTD_SIZE_T __nbytes =
87 ((__maxbits >> (_RWSTD_LOG2_CHAR_BITS + _RWSTD_LOG2_LONG_SIZE)) +
88 (0 != (__maxbits & (__wordbits - 1)))) << _RWSTD_LOG2_LONG_SIZE;
92 const _RWSTD_SIZE_T __nbytes =
93 (__maxbits / __wordbits + (0 != __maxbits % __wordbits))
101 for (_RWSTD_SIZE_T __i = 0; __i != __nchars; ++__i) {
103 if (_Traits::eq (__b1, __str [__i])) {
105 const _RWSTD_SIZE_T __bitno = __nbits - __i - 1;
108 __bits [__bitno / __wordbits] |= 1UL << __bitno % __wordbits;
118#undef _RWSTD_LOG2_CHAR_BITS
119#undef _RWSTD_LOG2_ULONG_SIZE
123template <_RWSTD_SIZE_T _Size,
class _CharT,
class _Traits>
124_STD::basic_istream<_CharT, _Traits>&
125__rw_extract_bitset (_STD::basic_istream<_CharT, _Traits> &__strm,
126 _STD::bitset<_Size> &__x)
128 typedef _STD::basic_istream<_CharT, _Traits> _Istream;
130 typename _Istream::iostate __err (__strm.goodbit);
133 _STD::bitset<_Size> __tmp;
135 _RWSTD_SIZE_T __bit = _Size;
140 const typename _Istream::sentry __ipfx (__strm);
147 typename _Traits::int_type __c = __strm.rdbuf ()->sgetc ();
149 for ( ; __bit; --__bit) {
151 if (_Traits::eq_int_type (_Traits::eof (), __c)) {
152 __err = __strm.eofbit;
158 __strm.narrow (_Traits::to_char_type (__c), _CharT ());
161 __tmp [__bit - 1] = 1;
162 else if (
'0' != __ch)
165 __c = __strm.rdbuf ()->snextc ();
173 __strm.setstate (__strm.badbit | _RW::__rw_rethrow);
176 if (_Size && _Size == __bit)
177 __err |= __strm.failbit;
182 __strm.setstate (__err);
#define _RWSTD_REQUIRES(pred, args)
#define _RWSTD_NAMESPACE(name)
#define _RWSTD_ERROR_INVALID_ARGUMENT
#define _RWSTD_ERROR_OUT_OF_RANGE