piranha  0.10
Public Member Functions | List of all members
piranha::safe_cast_impl< To, From, sc_float_to_int_enabler< To, From > > Struct Template Reference

Specialisation of piranha::safe_cast() for C++ floating-point to C++ integral conversions. More...

#include <piranha/safe_cast.hpp>

Public Member Functions

To operator() (const From &f) const
 Call operator. More...
 

Detailed Description

template<typename To, typename From>
struct piranha::safe_cast_impl< To, From, sc_float_to_int_enabler< To, From > >

Specialisation of piranha::safe_cast() for C++ floating-point to C++ integral conversions.

Note
This specialisation is enabled if From is a C++ floating-point type and To is a C++ integral type.

Definition at line 140 of file safe_cast.hpp.

Member Function Documentation

◆ operator()()

template<typename To , typename From >
To piranha::safe_cast_impl< To, From, sc_float_to_int_enabler< To, From > >::operator() ( const From &  f) const
inline

Call operator.

The call operator will first check that f is a finite integral value, and it will then invoke boost::numeric_cast() to perform the conversion.

Parameters
fconversion argument.
Returns
f safely converted to To.
Exceptions
piranha::safe_cast_failureif:
  • f is not finite or it has a nonzero fractional part,
  • boost::numeric_cast() raises an error.

Definition at line 154 of file safe_cast.hpp.


The documentation for this struct was generated from the following file: