Boost logo

Boost Users :

From: Matthew Bourdua (unknownmat_at_[hidden])
Date: 2008-07-13 22:54:48


Hello,

I'm receiving a compiler warning (MSVC8.0) that does not make sense to
me, and I wonder if this might be a boost related issue:

#include <vector>
#include <functional>
#include <boost/function.hpp>

int main()
{
    std::vector< std::size_t > sizes;
    std::vector< unsigned > data;
   
    boost::function< bool (unsigned, unsigned) > fn = std::greater<
unsigned >();
    fn( data.front(), 10 ); // NOTE: data is empty - will cause runtime
error
}

The warning I get is:
warning C4267: 'argument' : conversion from 'size_t' to 'unsigned int',
possible loss of data
referring to the last line in main().

This warning goes away if I do either of the following:
 - Comment out the std::vector< std::size_t > sizes - this one baffles me.
 - Use a 'naked' std::greater< unsigned >() instead of a
boost::function< bool (unsigned, unsigned) >() object.

I wonder if size_t is somehow redefined in boost in a way that might be
causing me some trouble?

Any help would be appreciated, thanks.

Matt


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