mardi 2 juin 2015

Is visual c++ std::isfinite() standard conforming?

I got a wrapper class that has a simple and light-weighted implicit conversion operator to double.

I like to use it as I would use a double, for example:

if (!std::isfinite(myVar)) ...

But visual c++ implementation of std::isfinite(double) is actually a template that get his argument by copy.

So my wrapper class copy constructor is called, and it is not light-weighted.

To avoid this, I have to write:

if (!std::isfinite((double)myVar)) ...

for every call :(

If visual c++ std::isfinite() was defined as is it on cppreference.com, I would not have to cast every call:

bool isfinite( float arg );
bool isfinite( double arg );
bool isfinite( long double arg );
bool isfinite( Integral arg );

I am not sure what the standard says about this. Is vc++ template std::isfinite standard-conforming ?

Should I report this as a bug on Microsoft connect ?

Should I define my own isfinite(double) that calls std::isfinite ?

edit

Or maybe it is a non-issue as in a release build the calls get inlined and no copy occurs ? (well I'll try to check it right now and update in a few minutes)

Aucun commentaire:

Enregistrer un commentaire