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

Specialisation of piranha::safe_cast() for conversions involving piranha::real. More...

#include <piranha/real.hpp>

Public Member Functions

template<typename T = To, integral_enabler< T > = 0>
operator() (const real &r) const
 Call operator, real to integral overload. More...
 
template<typename T = To, rational_enabler< T > = 0>
operator() (const real &r) const
 Call operator, real to rational overload. More...
 

Detailed Description

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

Specialisation of piranha::safe_cast() for conversions involving piranha::real.

Note
This specialisation is enabled if To is an integral type, piranha::mp_integer or piranha::mp_rational, and From is piranha::real.

Definition at line 2269 of file real.hpp.

Member Function Documentation

◆ operator()() [1/2]

template<typename To , typename From >
template<typename T = To, integral_enabler< T > = 0>
T piranha::safe_cast_impl< To, From, sc_real_enabler< To, From > >::operator() ( const real r) const
inline

Call operator, real to integral overload.

Note
This operator is enabled if To is an integral type or an instance of piranha::mp_integer.

The conversion will succeed if r is a finite integral value representable by the target type.

Parameters
rconversion argument.
Returns
r converted to To.
Exceptions
piranha::safe_cast_failureif the conversion fails.
unspecifiedany exception thrown by boost::lexical_cast().

Definition at line 2293 of file real.hpp.

◆ operator()() [2/2]

template<typename To , typename From >
template<typename T = To, rational_enabler< T > = 0>
T piranha::safe_cast_impl< To, From, sc_real_enabler< To, From > >::operator() ( const real r) const
inline

Call operator, real to rational overload.

Note
This operator is enabled if To is an instance of piranha::mp_rational.
Parameters
rconversion argument.
Returns
r converted to piranha::mp_rational.
Exceptions
piranha::safe_cast_failureif the conversion fails.
unspecifiedany exception thrown by boost::lexical_cast().

Definition at line 2323 of file real.hpp.


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