I want to perform a narrowing conversion of a vector of doubles to a vector of floats. And I do not want Visual Studio throwing warning C4244, "possible loss of data", i.e. narrowing conversion.
Please do not post comments or answers saying I should not do this. I am aware of the consequences. I just want to suppress the warning. It is not acceptable to disable the warning outside the scope of this specific function, e.g. globally via project settings.
My attempt at warning suppression does not work:
vector<float> DoubleVectorToFloat( vector<double> & x ){
#pragma warning( push )
#pragma warning( disable : 4244 )
return vector<float>( x.begin(), x.end() );
#pragma warning( pop )
}
Aucun commentaire:
Enregistrer un commentaire