|
Boost Users : |
From: Gottlob Frege (gottlobfrege_at_[hidden])
Date: 2007-03-20 10:13:36
On 3/16/07, Joaquín Mª López Muñoz <joaquin_at_[hidden]> wrote:
> Hello Andrew,
>
> Andrew Holden ha escrito:
>
> > Joaquín Mª López Muñoz wrote:
> > >
> > > Filip Konvi?ka ha escrito:
> > > >
> > > > Aye, I got the following warning that I could not get rid of (VC 7.1)
> > > >
> > > > C:\Boost\include\boost-1_33_1\boost\functional\hash\hash.hpp(132) :
> > > > warning C4267: 'argument' : conversion from 'size_t' to 'unsigned int',
> > > > possible loss of data
> > >
> > > [...]
> > >
> > > Looks like an overzealous or simply misguided warning. Can you please try
> > > the following?
> > >
> > > [...]
> > >
> > > Same warning? If so, you might ask for inclusion of a suitable #pragma
> > > warning(disable...) to the Boost.Hash author.
> >
> > Depending on your concern for portability, you might not want to dismiss this
> > warning. VC 7.1 and 8.0 provide it as part of their 64 bit portability warnings
> > (size_t will be 64 bits wide on 64-bit Windows, while unsigned int will remain
> > 32 bits). A better way to eliminate the warning might be to switch off the
> > 64 bit portability warnings in your project options.
>
> I'm not advocating that the warning be completely disabled, but only in a
> selective manner inside Boost.Hash code by using #pragma warning(push) and
> #pragma warning(pop):
>
> // boost/hash/hash.hpp
> #pragma warning(push)
> #pragma warning(disable:4267)
> ...
> #pragma warning(pop)
>
Maybe it would be better if boost::hash included a size_t version:
inline std::size_t hash_value(std::size_t v)
{
return v;
}
If necessary, in cases where std::size_t == unsigned int, it could
probably use is_same<T,U> to make sure both versions didn't exist and
cause warnings/errors.
Tony
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net