我收到警告,2008年武革委在《联邦法典》下汇编成册。 Boost, 1.39
include "boost/flyweight.hpp"
include "boost/flyweight/key_value.hpp"
class Foo
{
public:
Foo(const CString& item) : mfoo(item) {}
const CString& getkeyvalue() const {return mfoo;}
private:
const CString mfoo;
};
struct Conversion
{
const CString& operator() (const Foo& item) const {return item.getkeyvalue();}
};
using namespace boost::flyweights;
flyweight<key_value<CString, Foo, Conversion>, tag<Foo> > flyweight_test;
上述法典的最后一行会产生警告。
d:worksourcecodeoost1390oostfunctionalhashextensions.hpp(72) : warning C4800: const wchar_t *
: forcing value to bool true or false (performance warning)
d:worksourcecodeoost1390oostfunctionalhashextensions.hpp(71) : while compiling class template member function size_t boost::hash<T>::operator ()(const T &) const
with
[
T=ATL::CStringT<wchar_t,StrTraitMFC_DLL<wchar_t>>
]
d:worksourcecodeoost1390oostmulti_indexhashedindex.hpp(1159) : see reference to class template instantiation boost::hash<T> being compiled with
[
T=ATL::CStringT<wchar_t,StrTraitMFC_DLL<wchar_t>>
]
这一警告通过 ha工厂、MPL等进行。
为什么会发出警告,我如何纠正该守则,以便不发出警告?
Edit:
To fix, add below implementation of hash_value
template<typename CharType, typename TraitsType>
std::size_t hash_value(const ATL::CStringT<CharType, TraitsType>& s)
{
return CStringElementTraits<typename TraitsType>::Hash(s);
}