Skip to content

Commit

Permalink
better documentation of number conversion function
Browse files Browse the repository at this point in the history
  • Loading branch information
donbright committed Oct 24, 2015
1 parent cb69ab4 commit fa34694
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/boost-utils.h
Expand Up @@ -12,9 +12,14 @@ fs::path boostfs_uncomplete(fs::path const p, fs::path const base);
#include <boost/cast.hpp>
#include <sstream>

// convert number types (for example double to int) but print WARNING
// for failures during conversion. >0 Overflow: return max of Tout,
// <0 overflow return min, otherwise return 0. use std::numeric_limits
/* Convert number types (for example double to int) but print WARNING
for failures during conversion. This is useful for situations where it
is important to not fail silently during casting or conversion. (For
example, accidentally converting 64 bit types to 32 bit types, float to
int, etc).
For positive overflow, return max of Tout template type
For negative overflow, return min of Tout template type
On other failures, return 0. */
template <class Tout,class Tin> Tout boost_numeric_cast( Tin input )
{
Tout result = 0;
Expand Down

0 comments on commit fa34694

Please sign in to comment.