|
Boost : |
From: Alexandre Karev (alexandre.karev_at_[hidden])
Date: 2001-11-21 06:25:29
On Tue, 20 Nov 2001, Ullrich Koethe wrote:
u.koethe >On g++, this doesn't work with std::vector<bool> either, because
u.koethe >std::vector<bool>::operator[] returns a proxy (type _Bit_reference).
u.koethe >
u.koethe >BTW, on g++ 'sizeof(bool) == 4'. So Image<unsigned char> will be smaller
u.koethe >than Image<bool> unless the latter is packed, with all problems that the
u.koethe >use of proxies implies.
u.koethe >
On which platform 'sizeof(bool) == 4'?
[pcna49ak] ~ > g++ -v
Reading specs from
/usr/local/lib/gcc-lib/i686-pc-linux-gnu/egcs-2.91.66/specs
gcc version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)
[pcna49ak] ~ > cat aa.cc
#include <cstdio>
int main( int, char * [] ) {
bool var;
/*
//
*/
::fprintf( stdout, "sizeof( bool ) is %u\n", sizeof( var ) );
return( 0 );
}
[pcna49ak] ~ > g++ -o aa aa.cc
[pcna49ak] ~ > ./aa
sizeof( bool ) is 1
[pcna49ak] ~ >
This is exact the reason why I'm using my own boolean class with sizeof
== 4, because as far as sizeof( bool ) == 1, concurrent access to
neighboring boolean componets by different threads will require locking...
Sasha.
--- Alexandre Karev EP/CERN Alexandre.Karev_at_[hidden] "The most difficult thing is to prove the evident". Folk wisdom.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk