Take the 2-minute tour ×  Is it safe to do this?  double
darray[10]; vector<float> fvector;
fvector.insert(fvector.begin(), darray, darray + 10);  // double
to float conversion  // now work with fvector  VS2008 gives me a
warning about the double to float conversion. How do I get rid
of this warning? I don't think it makes sense to cast darray to
float* as that would change the step size (stride) of the
pointer.  Update: I know what the warning indicates. But unlike
the "afloat = adouble;" scenario where I can easily apply a
cast, I am unable to eliminate the warning in this case.  Edit:
I've edited the code so that darray is no longer a function
argument. Thanks to all those of you who pointed it out.
share|improve this question  5 Answers 5  up vote 3 down vote
accepted  Use std::transform() this allows you to provide a
conversion method. Then you just need a conversion method that
does not generate a warning:  #include <vector> #include
<algorithm> #include <iterator>  struct CastToFloat     float
operato