Re: Type cast problem with VC++ 2005 Express Edition
aslan wrote:
"Tim Roberts" <timr@probo.com>, iletisinde sunu yazdi,
Yes, but you are conveniently and repeatedly ignoring the most important
point. "std::vector<bool> a" is NOT the same as "bool a[32]". There is
an special optimization allowed for std::vectors of bool, which allows
them to be packed 8 to a byte. That CANNOT be done for "bool a[32]".
For example, this is legal:
std::vector<int> vi;
vi.resize(32);
int * pi = &vi[0];
After this, pi will point to a 128-byte piece of memory, with room for 32
ints. But when you do this:
std::vector<bool> vb;
vb.resize(32);
bool * pb = &vb[0];
No Sir,
I have tried it and I don't get any compile or run-time error with SGI STL
on my machine.
The STL is not standard C++. You can install it, but if you then rely on
things where it differs from the C++ standard library, you get exactly what
you got. Let me repeat that: The STL, as far as the C++ standard is
concerned is just a library. Since it also puts symbols into the 'std'
namespace, it could even be called a bad library, as that namespace is
reserved.
Aslan, why are you using the STL anyway? Development of it was abandoned
more than half a decade ago. Most parts of it have been incorporated into
the C++ standard (which is probably the reason many people confuse the
two), so they are available in a standard-conformant way there. I see no
reason to use the STL in modern code.
Uli
--
C++ FAQ: http://parashift.com/c++-faq-lite
Sator Laser GmbH
Gesch??ftsf??hrer: Thorsten F??cking, Amtsgericht Hamburg HR B62 932