The following code:
#include <cstdint>
#include <vector>
#include <boost/range/irange.hpp>
int main() {
int64_t first = 0, last = 10;
std::vector<double> result = boost::copy_range<std::vector<double>>(boost::irange(first, last));
}
generates the warning (and 100+ lines of templated call stack trace):
1>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xmemory0(600):
warning C4244: 'initializing' : conversion from 'unsigned __int64' to 'double', possible loss of data
I want to tell the compiler that I don't care that my int64_t
are being converted to double
. I also do not want to use a 32-bit int instead. I would usually use static_cast<double>(my64BitInt)
to solve this, but that won't work for a range. Right now I'm resorting to compiler pragmas to suppress the warning but that's not ideal.
Edit: Here's a pastebin with the full compiler output.
what Phil said;
However in this case, you could do much simpler using the iota algorithm:
#include <vector>
#include <boost/range/algorithm_ext.hpp>
int main() {
std::vector<double> result(10);
boost::iota(result, 0);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With