12 #include <type_traits> 46 template <
typename T,
typename U>
47 T
fromQ(
const U &in,
const int n);
53 template <
typename T,
typename U>
69 template <
typename T,
typename U>
70 T
floatToQ(
const U &in,
const int n);
76 template <
typename T,
typename U>
81 template <
typename T,
typename U>
82 T fromQImpl(
const U &in,
const int, std::false_type)
87 template <
typename T,
typename U>
88 T fromQImpl(
const U &in,
const int n, std::true_type)
93 template <
typename T,
typename U>
94 T fromQImpl(
const std::complex<U> &in,
const int, std::false_type)
99 template <
typename T,
typename U>
100 T fromQImpl(
const std::complex<U> &in,
const int n, std::true_type)
102 auto real = fromQ<typename T::value_type, U>(in.real(), n);
103 auto imag = fromQ<typename T::value_type, U>(in.imag(), n);
104 return T(real, imag);
107 template <
typename T,
typename U>
108 T floatToQImpl(
const U &in,
const int, std::false_type)
113 template <
typename T,
typename U>
114 T floatToQImpl(
const U &in,
const int n, std::true_type)
116 return T(std::ldexp(in, n));
119 template <
typename T,
typename U>
120 T floatToQImpl(
const std::complex<U> &in,
const int, std::false_type)
125 template <
typename T,
typename U>
126 T floatToQImpl(
const std::complex<U> &in,
const int n, std::true_type)
128 auto real = floatToQ<typename T::value_type, U>(in.real(), n);
129 auto imag = floatToQ<typename T::value_type, U>(in.imag(), n);
130 return T(real, imag);
135 static_assert(std::is_same<
typename Fundamental<std::complex<double>>::
Type,
double>::value,
"Fundamental of complex");
141 template <
typename T,
typename U>
144 return Pothos::Util::Detail::fromQImpl<T>(in, n, std::is_integral<typename Fundamental<U>::Type>());
147 template <
typename T,
typename U>
151 return Pothos::Util::Detail::fromQImpl<T>(in, n, std::is_integral<typename Fundamental<U>::Type>());
154 template <
typename T,
typename U>
157 return Pothos::Util::Detail::floatToQImpl<T>(in, n, std::is_integral<typename Fundamental<T>::Type>());
160 template <
typename T,
typename U>
164 return Pothos::Util::Detail::floatToQImpl<T>(in, n, std::is_integral<typename Fundamental<T>::Type>());
T floatToQ(const U &in, const int n)
Definition: QFormat.hpp:155
T Type
Definition: QFormat.hpp:23
Determine the fundamental data type of T for primitive types.
Definition: QFormat.hpp:21
Definition: ArchiveEntry.hpp:20
T Type
Definition: QFormat.hpp:30
T fromQ(const U &in, const int n)
Definition: QFormat.hpp:142