* Help on Biset
@ 2002-11-20 13:56 Siyan Li
2002-11-20 15:03 ` Gokhan Kisacikoglu
0 siblings, 1 reply; 3+ messages in thread
From: Siyan Li @ 2002-11-20 13:56 UTC (permalink / raw)
To: gcc-help
Hi,
I am fairly new to the list. If you think that I am saying something
stupid, please do correct me.
I am trying to use stl bitset with gcc. However, I found that the
.to_string() method is not implemented.
Here is the code I was trying to run,
#include <fstream>
#include <bitset>
int main(){
ofstream out;
out.open("bittry.txt");
int i = 97;
bitset<12> set1(i);
out << set1.to_string();
out.close();
return 1;
}
What I need to do is to try to output one bit at a time to a file... I
am trying to make a binary file(for example, "011" will be outputted as
bits "011", not string "011" to a file).
Please let me know if it is a but of Gcc and if it is, is there
anyways to get around it?
Thanks,
--
--
Yan
...
KeyServer: pgp.mit.edu; Index ID: s8li
Key fingerprint = 41B8 FD05 6598 A34A D564 EA73 F1DA 32F2 9EC2 DB0B
Dream as if you'll live forever;
Live as if you'll die tomorrow.
-------------------------------------------------------------------------------
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Help on Biset
2002-11-20 13:56 Help on Biset Siyan Li
@ 2002-11-20 15:03 ` Gokhan Kisacikoglu
2002-11-20 15:04 ` Gokhan Kisacikoglu
0 siblings, 1 reply; 3+ messages in thread
From: Gokhan Kisacikoglu @ 2002-11-20 15:03 UTC (permalink / raw)
To: Siyan Li; +Cc: gcc-help
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;
}
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Help on Biset
2002-11-20 15:03 ` Gokhan Kisacikoglu
@ 2002-11-20 15:04 ` Gokhan Kisacikoglu
0 siblings, 0 replies; 3+ messages in thread
From: Gokhan Kisacikoglu @ 2002-11-20 15:04 UTC (permalink / raw)
To: Siyan Li, gcc-help
Gokhan Kisacikoglu wrote:
>
> Would this work until the functionality is established in the sgi
> headers?
>
I meant the gcc headers, the code I sent is from the sgi's
implementation which is probably some hp implementation etc...
Gokhan
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2002-11-20 23:04 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-11-20 13:56 Help on Biset Siyan Li
2002-11-20 15:03 ` Gokhan Kisacikoglu
2002-11-20 15:04 ` Gokhan Kisacikoglu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).