vector<bool> warning 
Author Message
 vector<bool> warning

hi,

I'm trying to have a vector of "bool" values...

I've tried the following...

vector<bool> bVec(27);
and
vector<bool, allocator<bool> > bVector(27);

I get the following warning which is not in the help!!

"c:\vc5\include\xutility.h: warning 4804: '<' : unsafe use of type 'bool' in
operation"

Does anybody know why I get this error?  Am I doing something wrong?

Thanks in advance,

Tamara



Fri, 07 Jul 2000 03:00:00 GMT  
 vector<bool> warning

What Service Pack of the compiler are you using?  I'm using Visual C++ 5.0,
SP3.  The following works fine for me with no compiler warnings:

#include <windows.h>
#include <vector>

int WINAPI WinMain(HINSTANCE hinst, HINSTANCE hinstPrev,
    LPSTR pszCmdLine, int nCmdShow)
{
 std::vector<bool> vec(5);
 vec[0] = true;
 vec[1] = false;
 vec[2] = true;
 vec[3] = true;
 vec[4] = false;
 vec.push_back(true);
 vec.push_back(false);
 vec.push_back(true);
 vec.push_back(true);
 vec.push_back(false);

 for (std::vector<bool>::iterator it = vec.begin(); it != vec.end(); ++it)
 {
  OutputDebugString(*it ? "true" : "false");
  OutputDebugString("\n");
 }

 return 0;

Quote:
}



Sat, 08 Jul 2000 03:00:00 GMT  
 vector<bool> warning

Thanks,

That was it.  I had not patched up to sp3.  Doing so got rid of the warning!

Thanks again,
Tamara

Quote:

>What Service Pack of the compiler are you using?  I'm using Visual C++ 5.0,
>SP3.  The following works fine for me with no compiler warnings:

>#include <windows.h>
>#include <vector>

>int WINAPI WinMain(HINSTANCE hinst, HINSTANCE hinstPrev,
>    LPSTR pszCmdLine, int nCmdShow)
>{
> std::vector<bool> vec(5);
> vec[0] = true;
> vec[1] = false;
> vec[2] = true;
> vec[3] = true;
> vec[4] = false;
> vec.push_back(true);
> vec.push_back(false);
> vec.push_back(true);
> vec.push_back(true);
> vec.push_back(false);

> for (std::vector<bool>::iterator it = vec.begin(); it != vec.end(); ++it)
> {
>  OutputDebugString(*it ? "true" : "false");
>  OutputDebugString("\n");
> }

> return 0;
>}



Sat, 08 Jul 2000 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. vector<bool> warning

2. vector<bool> problem with VC++ 6.0

3. vector<bool>

4. Warnings for std::vector<std::string>

5. STL <vector> compiler warning

6. Compiler warning with vector<string>

7. <<<<<<<Parsing help, please>>>>>>>>

8. File Format conversion, ascii freeform -->.csv <-->.wk1<-->dbf<-->?HELP

9. <<<>>>Need C code advice with functions and sorting.<<<>>>

10. <><><>HELP<><><> PCMCIA Motorola Montana 33.6

11. >>>Windows Service<<<

12. valarray<bool> crashes

 

 
Powered by phpBB® Forum Software