kfr

Fast, modern C++ DSP framework, FFT, Sample Rate Conversion, FIR/IIR/Biquad Filters (SSE, AVX, AVX-512, ARM NEON)
Log | Files | Refs | README

commit 286b060d0e174459ede0b48bfc6cde2d6a4f3a5a
parent 7f532937d2c4a18f7e668ad945ed13cd565dddb7
Author: [email protected] <[email protected]>
Date:   Mon, 17 Oct 2016 07:51:17 +0300

cometa.hpp: map, scale and new CMT_ENABLE_IF_IMPL

Diffstat:
Minclude/kfr/cometa.hpp | 17+++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/include/kfr/cometa.hpp b/include/kfr/cometa.hpp @@ -422,6 +422,13 @@ struct cvals_t : ops::empty { return {}; } + + // MSVC requires static_cast<T> here: + template <typename Fn> + constexpr auto map(Fn&& fn) -> cvals_t<T, static_cast<T>(Fn()(values))...> + { + return {}; + } }; template <typename T> @@ -681,6 +688,12 @@ using csizeseq_t = cvalseq_t<size_t, size, start, step>; template <typename... List> using indicesfor_t = cvalseq_t<size_t, sizeof...(List), 0>; +template <size_t group, size_t... indices, size_t N = group * sizeof...(indices)> +constexpr inline auto scale(csizes_t<indices...> i) noexcept +{ + return i[csizeseq_t<N>() / csize_t<group>()] * csize_t<group>() + csizeseq_t<N>() % csize_t<group>(); +} + namespace details { @@ -724,9 +737,9 @@ struct unique_enum_impl }; }; -#ifdef CMT_COMPILER_MSVC +#if defined CMT_COMPILER_MSVC && !defined CMT_COMPILER_CLANG #define CMT_ENABLE_IF_IMPL(N, ...) \ - bool enable_ = (__VA_ARGS__), typename enabled_ = ::std::enable_if<enable_>::type, \ + bool enable_ = (__VA_ARGS__), typename enabled_ = typename ::std::enable_if<enable_>::type, \ typename cometa::details::unique_enum_impl<N>::type dummy_ = \ ::cometa::details::unique_enum_impl<N>::value