3 * Silicon Graphics Computer Systems, Inc.
8 * This material is provided "as is", with absolutely no warranty expressed
9 * or implied. Any use is at your own risk.
11 * Permission to use or copy this software for any purpose is hereby granted
12 * without fee, provided the above notices are retained on all copies.
13 * Permission to modify the code and to distribute modified code is granted,
14 * provided the above notices are retained, and a notice that the code was
15 * modified is included with the above copyright notice.
19 #ifndef _STLP_BITSET_H
20 #define _STLP_BITSET_H
22 // A bitset of size N has N % (sizeof(unsigned long) * CHAR_BIT) unused
23 // bits. (They are the high- order bits in the highest word.) It is
24 // a class invariant of class bitset<> that those unused bits are
27 // Most of the actual code isn't contained in bitset<> itself, but in the
28 // base class _Base_bitset. The base class works with whole words, not with
29 // individual bits. This allows us to specialize _Base_bitset for the
30 // important special case where the bitset is only a single word.
32 // The C++ standard does not define the precise semantics of operator[].
33 // In this implementation the const version of operator[] is equivalent
34 // to test(), except that it does no range checking. The non-const version
35 // returns a reference to a bit, again without doing any range checking.
38 #ifndef _STLP_INTERNAL_ALGOBASE_H
39 # include <stl/_algobase.h>
42 #ifndef _STLP_INTERNAL_ALLOC_H
43 # include <stl/_alloc.h>
46 #ifndef _STLP_INTERNAL_ITERATOR_H
47 # include <stl/_iterator.h>
50 #ifndef _STLP_INTERNAL_UNINITIALIZED_H
51 # include <stl/_uninitialized.h>
54 #ifndef _STLP_RANGE_ERRORS_H
55 # include <stl/_range_errors.h>
58 #ifndef _STLP_INTERNAL_STRING_H
59 # include <stl/_string.h>
62 #define __BITS_PER_WORD (CHAR_BIT*sizeof(unsigned long))
63 #define __BITSET_WORDS(__n) ((__n + __BITS_PER_WORD - 1)/__BITS_PER_WORD)
67 _STLP_MOVE_TO_PRIV_NAMESPACE
69 // structure to aid in counting bits
70 class _STLP_CLASS_DECLSPEC _Bs_G
73 //returns the number of bit set within the buffer between __beg and __end.
74 static size_t _S_count(const unsigned char *__beg, const unsigned char *__end)
75 #if defined (_STLP_USE_NO_IOSTREAMS)
78 for (; __beg != __end; ++__beg) {
79 for (size_t i = 0; i < (sizeof(unsigned char) * 8); ++i) {
80 if ((*__beg & (1 << i)) != 0) { ++__result; }
88 // Mapping from 8 bit unsigned integers to the index of the first one bit set:
89 static unsigned char _S_first_one(unsigned char __x)
90 #if defined (_STLP_USE_NO_IOSTREAMS)
92 for (unsigned char i = 0; i < (sizeof(unsigned char) * 8); ++i) {
93 if ((__x & (1 << i)) != 0) { return i; }
103 // Base class: general case.
107 struct _Base_bitset {
108 typedef unsigned long _WordT;
110 _WordT _M_w[_Nw]; // 0 is the least significant word.
112 _Base_bitset() { _M_do_reset(); }
114 _Base_bitset(unsigned long __val) {
119 static size_t _STLP_CALL _S_whichword( size_t __pos ) {
120 return __pos / __BITS_PER_WORD;
122 static size_t _STLP_CALL _S_whichbyte( size_t __pos ) {
123 return (__pos % __BITS_PER_WORD) / CHAR_BIT;
125 static size_t _STLP_CALL _S_whichbit( size_t __pos ) {
126 return __pos % __BITS_PER_WORD;
128 static _WordT _STLP_CALL _S_maskbit( size_t __pos ) {
129 return __STATIC_CAST(_WordT,1) << _S_whichbit(__pos);
132 _WordT& _M_getword(size_t __pos) { return _M_w[_S_whichword(__pos)]; }
133 _WordT _M_getword(size_t __pos) const { return _M_w[_S_whichword(__pos)]; }
135 _WordT& _M_hiword() { return _M_w[_Nw - 1]; }
136 _WordT _M_hiword() const { return _M_w[_Nw - 1]; }
138 void _M_do_and(const _Base_bitset<_Nw>& __x) {
139 for ( size_t __i = 0; __i < _Nw; __i++ ) {
140 _M_w[__i] &= __x._M_w[__i];
144 void _M_do_or(const _Base_bitset<_Nw>& __x) {
145 for ( size_t __i = 0; __i < _Nw; __i++ ) {
146 _M_w[__i] |= __x._M_w[__i];
150 void _M_do_xor(const _Base_bitset<_Nw>& __x) {
151 for ( size_t __i = 0; __i < _Nw; __i++ ) {
152 _M_w[__i] ^= __x._M_w[__i];
156 void _M_do_left_shift(size_t __shift);
158 void _M_do_right_shift(size_t __shift);
161 for ( size_t __i = 0; __i < _Nw; __i++ ) {
162 _M_w[__i] = ~_M_w[__i];
167 for ( size_t __i = 0; __i < _Nw; __i++ ) {
168 _M_w[__i] = ~__STATIC_CAST(_WordT,0);
172 void _M_do_reset() { memset(_M_w, 0, _Nw * sizeof(_WordT)); }
174 bool _M_is_equal(const _Base_bitset<_Nw>& __x) const {
175 for (size_t __i = 0; __i < _Nw; ++__i) {
176 if (_M_w[__i] != __x._M_w[__i])
182 bool _M_is_any() const {
183 for ( size_t __i = 0; __i < _Nw ; __i++ ) {
184 if ( _M_w[__i] != __STATIC_CAST(_WordT,0) )
190 size_t _M_do_count() const {
191 const unsigned char* __byte_ptr = (const unsigned char*)_M_w;
192 const unsigned char* __end_ptr = (const unsigned char*)(_M_w+_Nw);
194 return _Bs_G::_S_count(__byte_ptr, __end_ptr);
197 unsigned long _M_do_to_ulong() const;
199 // find first "on" bit
200 size_t _M_do_find_first(size_t __not_found) const;
202 // find the next "on" bit that follows "prev"
203 size_t _M_do_find_next(size_t __prev, size_t __not_found) const;
207 // Base class: specialization for a single word.
210 struct _Base_bitset<1UL> {
211 typedef unsigned long _WordT;
212 typedef _Base_bitset<1UL> _Self;
216 _Base_bitset( void ) : _M_w(0) {}
217 _Base_bitset(unsigned long __val) : _M_w(__val) {}
219 static size_t _STLP_CALL _S_whichword( size_t __pos ) {
220 return __pos / __BITS_PER_WORD ;
222 static size_t _STLP_CALL _S_whichbyte( size_t __pos ) {
223 return (__pos % __BITS_PER_WORD) / CHAR_BIT;
225 static size_t _STLP_CALL _S_whichbit( size_t __pos ) {
226 return __pos % __BITS_PER_WORD;
228 static _WordT _STLP_CALL _S_maskbit( size_t __pos ) {
229 return (__STATIC_CAST(_WordT,1)) << _S_whichbit(__pos);
232 _WordT& _M_getword(size_t) { return _M_w; }
233 _WordT _M_getword(size_t) const { return _M_w; }
235 _WordT& _M_hiword() { return _M_w; }
236 _WordT _M_hiword() const { return _M_w; }
238 void _M_do_and(const _Self& __x) { _M_w &= __x._M_w; }
239 void _M_do_or(const _Self& __x) { _M_w |= __x._M_w; }
240 void _M_do_xor(const _Self& __x) { _M_w ^= __x._M_w; }
241 void _M_do_left_shift(size_t __shift) { _M_w <<= __shift; }
242 void _M_do_right_shift(size_t __shift) { _M_w >>= __shift; }
243 void _M_do_flip() { _M_w = ~_M_w; }
244 void _M_do_set() { _M_w = ~__STATIC_CAST(_WordT,0); }
245 void _M_do_reset() { _M_w = 0; }
247 bool _M_is_equal(const _Self& __x) const {
248 return _M_w == __x._M_w;
250 bool _M_is_any() const {
254 size_t _M_do_count() const {
255 const unsigned char* __byte_ptr = (const unsigned char*)&_M_w;
256 const unsigned char* __end_ptr = ((const unsigned char*)&_M_w)+sizeof(_M_w);
257 return _Bs_G::_S_count(__byte_ptr, __end_ptr);
260 unsigned long _M_do_to_ulong() const { return _M_w; }
262 inline size_t _M_do_find_first(size_t __not_found) const;
264 // find the next "on" bit that follows "prev"
265 inline size_t _M_do_find_next(size_t __prev, size_t __not_found) const;
269 // ------------------------------------------------------------
271 // Definitions of should-be-non-inline functions from the single-word version of
275 _Base_bitset<1UL>::_M_do_find_first(size_t __not_found) const {
276 // typedef unsigned long _WordT;
277 _WordT __thisword = _M_w;
279 if ( __thisword != __STATIC_CAST(_WordT,0) ) {
280 // find byte within word
281 for ( size_t __j = 0; __j < sizeof(_WordT); __j++ ) {
282 unsigned char __this_byte
283 = __STATIC_CAST(unsigned char,(__thisword & (~(unsigned char)0)));
285 return __j*CHAR_BIT + _Bs_G::_S_first_one(__this_byte);
287 __thisword >>= CHAR_BIT;
290 // not found, so return a value that indicates failure.
295 _Base_bitset<1UL>::_M_do_find_next(size_t __prev,
296 size_t __not_found ) const {
297 // make bound inclusive
300 // check out of bounds
301 if ( __prev >= __BITS_PER_WORD )
304 // search first (and only) word
305 _WordT __thisword = _M_w;
307 // mask off bits below bound
308 __thisword &= (~__STATIC_CAST(_WordT,0)) << _S_whichbit(__prev);
310 if ( __thisword != __STATIC_CAST(_WordT,0) ) {
311 // find byte within word
312 // get first byte into place
313 __thisword >>= _S_whichbyte(__prev) * CHAR_BIT;
314 for ( size_t __j = _S_whichbyte(__prev); __j < sizeof(_WordT); __j++ ) {
315 unsigned char __this_byte
316 = __STATIC_CAST(unsigned char,(__thisword & (~(unsigned char)0)));
318 return __j*CHAR_BIT + _Bs_G::_S_first_one(__this_byte);
320 __thisword >>= CHAR_BIT;
324 // not found, so return a value that indicates failure.
326 } // end _M_do_find_next
329 // ------------------------------------------------------------
330 // Helper class to zero out the unused high-order bits in the highest word.
332 template <size_t _Extrabits> struct _Sanitize {
333 static void _STLP_CALL _M_do_sanitize(unsigned long& __val)
334 { __val &= ~((~__STATIC_CAST(unsigned long,0)) << _Extrabits); }
337 _STLP_TEMPLATE_NULL struct _Sanitize<0UL> {
338 static void _STLP_CALL _M_do_sanitize(unsigned long) {}
341 _STLP_MOVE_TO_STD_NAMESPACE
343 // ------------------------------------------------------------
345 // _Nb may be any nonzero number of type size_t.
347 class bitset : public _STLP_PRIV _Base_bitset<__BITSET_WORDS(_Nb) > {
349 enum { _Words = __BITSET_WORDS(_Nb) } ;
352 typedef _STLP_PRIV _Base_bitset< _Words > _Base;
354 void _M_do_sanitize() {
355 _STLP_PRIV _Sanitize<_Nb%__BITS_PER_WORD >::_M_do_sanitize(this->_M_hiword());
358 typedef unsigned long _WordT;
360 friend struct reference;
364 typedef _STLP_PRIV _Base_bitset<_Words > _Bitset_base;
365 typedef bitset<_Nb> _Bitset;
370 // should be left undefined
373 reference( _Bitset& __b, size_t __pos ) {
374 _M_wp = &__b._M_getword(__pos);
375 _M_bpos = _Bitset_base::_S_whichbit(__pos);
382 reference& operator=(bool __x) {
384 *_M_wp |= _Bitset_base::_S_maskbit(_M_bpos);
386 *_M_wp &= ~_Bitset_base::_S_maskbit(_M_bpos);
391 // for b[i] = b[__j];
392 reference& operator=(const reference& __j) {
393 if ( (*(__j._M_wp) & _Bitset_base::_S_maskbit(__j._M_bpos)) )
394 *_M_wp |= _Bitset_base::_S_maskbit(_M_bpos);
396 *_M_wp &= ~_Bitset_base::_S_maskbit(_M_bpos);
402 bool operator~() const { return (*(_M_wp) & _Bitset_base::_S_maskbit(_M_bpos)) == 0; }
405 operator bool() const { return (*(_M_wp) & _Bitset_base::_S_maskbit(_M_bpos)) != 0; }
409 *_M_wp ^= _Bitset_base::_S_maskbit(_M_bpos);
414 // 23.3.5.1 constructors:
417 bitset(unsigned long __val) : _STLP_PRIV _Base_bitset<_Words>(__val) { _M_do_sanitize(); }
419 #if defined (_STLP_MEMBER_TEMPLATES)
420 template<class _CharT, class _Traits, class _Alloc>
421 explicit bitset(const basic_string<_CharT,_Traits,_Alloc>& __s,
423 : _STLP_PRIV _Base_bitset<_Words >() {
424 if (__pos > __s.size())
425 __stl_throw_out_of_range("bitset");
426 _M_copy_from_string(__s, __pos,
427 basic_string<_CharT, _Traits, _Alloc>::npos);
429 template<class _CharT, class _Traits, class _Alloc>
430 bitset(const basic_string<_CharT, _Traits, _Alloc>& __s,
433 : _STLP_PRIV _Base_bitset<_Words >() {
434 if (__pos > __s.size())
435 __stl_throw_out_of_range("bitset");
436 _M_copy_from_string(__s, __pos, __n);
438 #else /* _STLP_MEMBER_TEMPLATES */
439 explicit bitset(const string& __s,
441 size_t __n = (size_t)-1)
442 : _STLP_PRIV _Base_bitset<_Words >() {
443 if (__pos > __s.size())
444 __stl_throw_out_of_range("bitset");
445 _M_copy_from_string(__s, __pos, __n);
447 #endif /* _STLP_MEMBER_TEMPLATES */
449 // 23.3.5.2 bitset operations:
450 bitset<_Nb>& operator&=(const bitset<_Nb>& __rhs) {
451 this->_M_do_and(__rhs);
455 bitset<_Nb>& operator|=(const bitset<_Nb>& __rhs) {
456 this->_M_do_or(__rhs);
460 bitset<_Nb>& operator^=(const bitset<_Nb>& __rhs) {
461 this->_M_do_xor(__rhs);
465 bitset<_Nb>& operator<<=(size_t __pos) {
466 this->_M_do_left_shift(__pos);
467 this->_M_do_sanitize();
471 bitset<_Nb>& operator>>=(size_t __pos) {
472 this->_M_do_right_shift(__pos);
473 this->_M_do_sanitize();
479 // Versions of single-bit set, reset, flip, test with no range checking.
482 bitset<_Nb>& _Unchecked_set(size_t __pos) {
483 this->_M_getword(__pos) |= _STLP_PRIV _Base_bitset<_Words > ::_S_maskbit(__pos);
487 bitset<_Nb>& _Unchecked_set(size_t __pos, int __val) {
489 this->_M_getword(__pos) |= this->_S_maskbit(__pos);
491 this->_M_getword(__pos) &= ~ this->_S_maskbit(__pos);
496 bitset<_Nb>& _Unchecked_reset(size_t __pos) {
497 this->_M_getword(__pos) &= ~ this->_S_maskbit(__pos);
501 bitset<_Nb>& _Unchecked_flip(size_t __pos) {
502 this->_M_getword(__pos) ^= this->_S_maskbit(__pos);
506 bool _Unchecked_test(size_t __pos) const {
507 return (this->_M_getword(__pos) & this->_S_maskbit(__pos)) != __STATIC_CAST(_WordT,0);
510 // Set, reset, and flip.
514 this->_M_do_sanitize();
518 bitset<_Nb>& set(size_t __pos) {
520 __stl_throw_out_of_range("bitset");
521 return _Unchecked_set(__pos);
524 bitset<_Nb>& set(size_t __pos, int __val) {
526 __stl_throw_out_of_range("bitset");
527 return _Unchecked_set(__pos, __val);
530 bitset<_Nb>& reset() {
535 bitset<_Nb>& reset(size_t __pos) {
537 __stl_throw_out_of_range("bitset");
539 return _Unchecked_reset(__pos);
542 bitset<_Nb>& flip() {
544 this->_M_do_sanitize();
548 bitset<_Nb>& flip(size_t __pos) {
550 __stl_throw_out_of_range("bitset");
552 return _Unchecked_flip(__pos);
555 bitset<_Nb> operator~() const {
556 return bitset<_Nb>(*this).flip();
561 reference operator[](size_t __pos) { return reference(*this,__pos); }
562 bool operator[](size_t __pos) const { return _Unchecked_test(__pos); }
564 unsigned long to_ulong() const { return this->_M_do_to_ulong(); }
566 #if defined (_STLP_MEMBER_TEMPLATES) && !defined (_STLP_NO_EXPLICIT_FUNCTION_TMPL_ARGS)
567 template <class _CharT, class _Traits, class _Alloc>
568 basic_string<_CharT, _Traits, _Alloc> to_string() const {
569 basic_string<_CharT, _Traits, _Alloc> __result;
570 _M_copy_to_string(__result);
574 string to_string() const {
576 _M_copy_to_string(__result);
579 #endif /* _STLP_EXPLICIT_FUNCTION_TMPL_ARGS */
581 size_t count() const { return this->_M_do_count(); }
583 size_t size() const { return _Nb; }
585 bool operator==(const bitset<_Nb>& __rhs) const {
586 return this->_M_is_equal(__rhs);
588 bool operator!=(const bitset<_Nb>& __rhs) const {
589 return !this->_M_is_equal(__rhs);
592 bool test(size_t __pos) const {
594 __stl_throw_out_of_range("bitset");
596 return _Unchecked_test(__pos);
599 bool any() const { return this->_M_is_any(); }
600 bool none() const { return !this->_M_is_any(); }
602 bitset<_Nb> operator<<(size_t __pos) const {
603 bitset<_Nb> __result(*this);
604 __result <<= __pos ; return __result;
606 bitset<_Nb> operator>>(size_t __pos) const {
607 bitset<_Nb> __result(*this);
608 __result >>= __pos ; return __result;
611 #if !defined (_STLP_NO_EXTENSIONS)
613 // EXTENSIONS: bit-find operations. These operations are
614 // experimental, and are subject to change or removal in future
618 // find the index of the first "on" bit
619 size_t _Find_first() const
620 { return this->_M_do_find_first(_Nb); }
622 // find the index of the next "on" bit after prev
623 size_t _Find_next( size_t __prev ) const
624 { return this->_M_do_find_next(__prev, _Nb); }
628 // Definitions of should-be non-inline member functions.
630 #if defined (_STLP_MEMBER_TEMPLATES)
631 template<class _CharT, class _Traits, class _Alloc>
632 void _M_copy_from_string(const basic_string<_CharT,_Traits,_Alloc>& __s,
633 size_t __pos, size_t __n) {
635 void _M_copy_from_string(const string& __s,
636 size_t __pos, size_t __n) {
637 typedef typename string::traits_type _Traits;
641 const size_t __Nbits = (min) (__tmp, (min) (__n, __s.size() - __pos));
642 for ( size_t __i= 0; __i < __Nbits; ++__i) {
643 typename _Traits::int_type __k = _Traits::to_int_type(__s[__pos + __Nbits - __i - 1]);
648 __stl_throw_invalid_argument("bitset");
652 #if defined (_STLP_MEMBER_TEMPLATES)
653 template <class _CharT, class _Traits, class _Alloc>
654 void _M_copy_to_string(basic_string<_CharT, _Traits, _Alloc>& __s) const
656 void _M_copy_to_string(string& __s) const
659 __s.assign(_Nb, '0');
661 for (size_t __i = 0; __i < _Nb; ++__i) {
662 if (_Unchecked_test(__i))
663 __s[_Nb - 1 - __i] = '1';
667 #if defined (_STLP_NON_TYPE_TMPL_PARAM_BUG)
668 bitset<_Nb> operator&(const bitset<_Nb>& __y) const {
669 bitset<_Nb> __result(*this);
673 bitset<_Nb> operator|(const bitset<_Nb>& __y) const {
674 bitset<_Nb> __result(*this);
678 bitset<_Nb> operator^(const bitset<_Nb>& __y) const {
679 bitset<_Nb> __result(*this);
686 // ------------------------------------------------------------
688 // 23.3.5.3 bitset operations:
690 #if ! defined (_STLP_NON_TYPE_TMPL_PARAM_BUG)
691 template <size_t _Nb>
692 inline bitset<_Nb> _STLP_CALL
693 operator&(const bitset<_Nb>& __x,
694 const bitset<_Nb>& __y) {
695 bitset<_Nb> __result(__x);
701 template <size_t _Nb>
702 inline bitset<_Nb> _STLP_CALL
703 operator|(const bitset<_Nb>& __x,
704 const bitset<_Nb>& __y) {
705 bitset<_Nb> __result(__x);
710 template <size_t _Nb>
711 inline bitset<_Nb> _STLP_CALL
712 operator^(const bitset<_Nb>& __x,
713 const bitset<_Nb>& __y) {
714 bitset<_Nb> __result(__x);
719 #if !defined (_STLP_USE_NO_IOSTREAMS)
723 # if !(defined (_STLP_MSVC) || (_STLP_MSVC < 1300)) && \
724 !(defined(__SUNPRO_CC) || (__SUNPRO_CC < 0x500))
726 #ifndef _STLP_INTERNAL_IOSFWD
727 # include <stl/_iosfwd.h>
730 _STLP_BEGIN_NAMESPACE
732 template <class _CharT, class _Traits, size_t _Nb>
733 basic_istream<_CharT, _Traits>& _STLP_CALL
734 operator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Nb>& __x);
736 template <class _CharT, class _Traits, size_t _Nb>
737 basic_ostream<_CharT, _Traits>& _STLP_CALL
738 operator<<(basic_ostream<_CharT, _Traits>& __os, const bitset<_Nb>& __x);
742 #ifndef _STLP_STRING_IO_H
743 # include <stl/_string_io.h> //includes _istream.h and _ostream.h
746 _STLP_BEGIN_NAMESPACE
748 template <size_t _Nb>
750 operator>>(istream& __is, bitset<_Nb>& __x) {
751 typedef typename string::traits_type _Traits;
756 typename istream::sentry __sentry(__is);
758 streambuf* __buf = __is.rdbuf();
759 for (size_t __i = 0; __i < _Nb; ++__i) {
760 static typename _Traits::int_type __eof = _Traits::eof();
762 typename _Traits::int_type __c1 = __buf->sbumpc();
763 if (_Traits::eq_int_type(__c1, __eof)) {
764 __is.setstate(ios_base::eofbit);
768 typename _Traits::char_type __c2 = _Traits::to_char_type(__c1);
769 char __c = __is.narrow(__c2, '*');
771 if (__c == '0' || __c == '1')
772 __tmp.push_back(__c);
773 else if (_Traits::eq_int_type(__buf->sputbackc(__c2), __eof)) {
774 __is.setstate(ios_base::failbit);
781 __is.setstate(ios_base::failbit);
783 __x._M_copy_from_string(__tmp, __STATIC_CAST(size_t,0), _Nb);
789 template <size_t _Nb>
791 operator<<(ostream& __os, const bitset<_Nb>& __x) {
793 __x._M_copy_to_string(__tmp);
794 return __os << __tmp;
797 # if !defined (_STLP_NO_WCHAR_T)
799 template <size_t _Nb>
801 operator>>(wistream& __is, bitset<_Nb>& __x) {
802 typedef typename wstring::traits_type _Traits;
807 typename wistream::sentry __sentry(__is);
809 wstreambuf* __buf = __is.rdbuf();
810 for (size_t __i = 0; __i < _Nb; ++__i) {
811 static typename _Traits::int_type __eof = _Traits::eof();
813 typename _Traits::int_type __c1 = __buf->sbumpc();
814 if (_Traits::eq_int_type(__c1, __eof)) {
815 __is.setstate(ios_base::eofbit);
819 typename _Traits::char_type __c2 = _Traits::to_char_type(__c1);
820 char __c = __is.narrow(__c2, '*');
822 if (__c == '0' || __c == '1')
823 __tmp.push_back(__c);
824 else if (_Traits::eq_int_type(__buf->sputbackc(__c2), __eof)) {
825 __is.setstate(ios_base::failbit);
832 __is.setstate(ios_base::failbit);
834 __x._M_copy_from_string(__tmp, __STATIC_CAST(size_t,0), _Nb);
840 template <size_t _Nb>
842 operator<<(wostream& __os, const bitset<_Nb>& __x) {
844 __x._M_copy_to_string(__tmp);
845 return __os << __tmp;
848 # endif /* _STLP_NO_WCHAR_T */
852 #endif /* _STLP_NON_TYPE_TMPL_PARAM_BUG */
858 #undef __BITS_PER_WORD
859 #undef __BITSET_WORDS
861 #if !defined (_STLP_LINK_TIME_INSTANTIATION)
862 # include <stl/_bitset.c>
865 #endif /* _STLP_BITSET_H */