JayBeams
0.1
Another project to have fun coding.
jb
complex_traits.hpp
Go to the documentation of this file.
1
#ifndef jb_complex_traits_hpp
2
#define jb_complex_traits_hpp
3
4
#include <complex>
5
6
namespace
jb
{
7
8
/**
9
* Generic function to extract the floating point type of std::complex.
10
*
11
* Some of the algorithms and data structures in JayBeams need to work
12
* for both std::complex<> and for primitive floating point values
13
* such as 'float'. These functions sometimes need a generic way to
14
* extract the 'T' parameter in a std::complex<T>. This function can
15
* be used to perform such conversions, for example:
16
*
17
* @code
18
* template<typename sample_t> class Foo {
19
* typedef typename jb::extra_value_type<sample_t>::precision prec;
20
* prec epsilon = std::numeric_limits<prec>::epsilon();
21
* };
22
* @endcode
23
*
24
* Such code would work whether sample_t is a std::complex<T> or a
25
* primitive floating point value.
26
*/
27
template
<
typename
T>
28
struct
extract_value_type
{
29
typedef
T
precision
;
30
};
31
32
/// Partial specialization of jb::extract_value_type for std::complex.
33
template
<
typename
T>
34
struct
extract_value_type
<
std
::complex<T>> {
35
typedef
T
precision
;
36
};
37
38
}
// namespace jb
39
40
#endif // jb_complex_traits_hpp
std
STL namespace.
jb::extract_value_type
Generic function to extract the floating point type of std::complex.
Definition:
complex_traits.hpp:28
jb::extract_value_type::precision
T precision
Definition:
complex_traits.hpp:29
jb::extract_value_type< std::complex< T > >::precision
T precision
Definition:
complex_traits.hpp:35
jb
The top-level namespace for the JayBeams library.
Definition:
as_hhmmss.hpp:7
Generated by
1.8.13