This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Help on Biset
- From: Gokhan Kisacikoglu <kisa at centropolisfx dot com>
- To: Siyan Li <s8li at calum dot csclub dot uwaterloo dot ca>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Wed, 20 Nov 2002 15:10:11 -0800
- Subject: Re: Help on Biset
- Organization: Centropolis Effects, LLC
- References: <20021120215444.GA7174@csclub.uwaterloo.ca>
- Reply-to: kisa at centropolisfx dot com
Would this work until the functionality is established in the sgi
headers?
#include <iostream>
#include <bitset>
using namespace std;
template <size_t _Nb, class _WordT>
string &operator << (string &_s, bitset <_Nb, _WordT> _b)
{
_s.assign(_Nb, '0');
for (size_t i = 0; i < _Nb; ++i)
if (_b.test(i)) _s[_Nb - 1 - i] = '1';
return _s;
}
template <size_t _Nb, class _WordT>
ostream &operator << (ostream &_s, bitset <_Nb, _WordT> _b)
{
string s;
s << _b;
_s << s;
return _s;
}
int
main(void)
{
bitset <12> b( 96 );
string s;
s << b;
cerr << s << " " << b << endl;
}