A: 

I compile with /Wall which causes Boost to generate all sorts of warnings. Furthermore, I instruct the compiler to treat all warnings as errors, so it becomes necessary to have no warnings at all.

In order to avoid getting any warnings while compiling the Boost headers, I use #pragma warning to temporarily lower the warning level as low as possible and turn off any remaining warnings while processing the Boost headers:

// set minimal warning level
#pragma warning(push,0)
// some warnings still occur at this level
// if necessary, disable specific warnings not covered by previous pragma
#pragma warning(disable:4800)

#include 

// restore warning level
#pragma warning(pop)

This makes sure my code is compiled with the highest level of error checking possible while code the I have no control over can still compile successfully.

The only other options I can see are to ignore the warnings or maintain a patched version of the Boost code until those warnings are fixed, neither of which is very appealing.

Ferruccio
I'm not really looking to disable the warning. Thanks for the suggestion anyway.
Chris Bednarski
A: 

I don't know how to correct that warning but you can turn it off by adding the code below to your cpp file:

#pragma warning(disable:4800)

Take a look at MSDN for further reference.

erelender
Not looking to disable warning. This is off topic.
Chris Bednarski
+1  A: 

The source of the warning is not in your code. You'd have to fix the offending Boost code.

MSalters
+1  A: 

One of the classes in flyweight probably uses the hash_value functions (or the wrapper class hash) to calculate a hash value from a ATL::CString. This is not defined in boost directly, so you'll need to provide an implementation:

std::size_t hash_value(const ATL::CString& s)
{
     // ...
}

Just looking at your compiler output, it seems that CString itself is templated, so you would implement

template<typename CharType, typename TraitsType>
std::size_t hash_value(const ATL::CString<CharType, TraitsType>& s)
{
     // calculate hash e.g. by calling hash_value(const std::string&)
}
MP24
Great lead. Indeed, the hash_value was being generated based on bool. Totally incorrect in this case. Implementation provided in the original question.
Chris Bednarski
+1  A: 

The C4800 warning is emitted by the compiler, when it must convert a int expression to a bool.

E.g. :

int k = 11;
bool f()
{ return k; }

The int expression k, is transformed from the internal definition of

k == 0 => *false*
k != 0 => *true*

to the bool Definition of

b == false (internally == 0) => *false*
b == true  (internally == 1) => *true*

Because any value (other then 0) may represent true in C++, the compiler has to convert k into a bool.

As the warning rightfully states, this conversion might present a performance hit.

NB: This warning may be a bit superfluous, because the compiler normally extracts the right meaning from the code, and optimizes this away.

Pseudo C code which the compiler would create from my sample code :

char f()
{
    if( k )
       return (char) 1;
    return (char) 0;
}
Christopher