12 #include <type_traits> 34 template <
typename T,
typename U>
35 typename std::enable_if<std::is_floating_point<U>::value, T>::type
36 fromQ(
const U &in,
const int = 0)
41 template <
typename T,
typename U>
42 typename std::enable_if<std::is_integral<U>::value, T>::type
43 fromQ(
const U &in,
const int n =
sizeof(U)*4)
48 template <
typename T,
typename U>
49 typename std::enable_if<std::is_floating_point<U>::value, T>::type
50 fromQ(
const std::complex<U> &in,
const int = 0)
55 template <
typename T,
typename U>
56 typename std::enable_if<std::is_integral<U>::value, T>::type
57 fromQ(
const std::complex<U> &in,
const int n =
sizeof(U)*4)
59 auto real = fromQ<typename T::value_type, U>(in.real(), n);
60 auto imag = fromQ<typename T::value_type, U>(in.imag(), n);
81 template <
typename T,
typename U>
82 typename std::enable_if<std::is_floating_point<T>::value, T>::type
88 template <
typename T,
typename U>
89 typename std::enable_if<std::is_integral<T>::value, T>::type
90 floatToQ(
const U &in,
const int n =
sizeof(T)*4)
92 return T(std::ldexp(in, n));
95 template <
typename T,
typename U>
96 typename std::enable_if<std::is_floating_point<typename T::value_type>::value, T>::type
97 floatToQ(
const std::complex<U> &in,
const int = 0)
102 template <
typename T,
typename U>
103 typename std::enable_if<std::is_integral<typename T::value_type>::value, T>::type
104 floatToQ(
const std::complex<U> &in,
const int n =
sizeof(
typename T::value_type)*4)
106 auto real = floatToQ<typename T::value_type, U>(in.real(), n);
107 auto imag = floatToQ<typename T::value_type, U>(in.imag(), n);
108 return T(real, imag);
std::enable_if< std::is_floating_point< T >::value, T >::type floatToQ(const U &in, const int=0)
Definition: QFormat.hpp:83
std::enable_if< std::is_floating_point< U >::value, T >::type fromQ(const U &in, const int=0)
Definition: QFormat.hpp:36
Definition: Testing.hpp:134