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 f7dde7d93d8c2031bc23209bdc904b5505ef0308
parent 5780b622eea2d8fa2e43c8080ebcba8dceaf33d3
Author: d.levin256@gmail.com <d.levin256@gmail.com>
Date:   Wed, 24 Aug 2016 22:31:30 +0300

Access to arguments in expression class

Diffstat:
Minclude/kfr/base/expression.hpp | 4++--
Mtests/vec_test.cpp | 14++++++++++++++
2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/include/kfr/base/expression.hpp b/include/kfr/base/expression.hpp @@ -74,9 +74,9 @@ struct expression : input_expression CMT_INLINE void begin_block(size_t size) const { begin_block_impl(size, indicesfor_t<Args...>()); } CMT_INLINE void end_block(size_t size) const { end_block_impl(size, indicesfor_t<Args...>()); } -protected: std::tuple<Args...> args; +protected: template <size_t... indices> constexpr size_type size_impl(csizes_t<indices...>) const noexcept { @@ -146,7 +146,7 @@ struct expression_scalar : input_expression expression_scalar() = delete; constexpr expression_scalar(const T& val) noexcept : val(val) {} constexpr expression_scalar(const vec<T, width>& val) noexcept : val(val) {} - const vec<T, width> val; + vec<T, width> val; template <typename U, size_t N> CMT_INLINE vec<U, N> operator()(cinput_t, size_t, vec_t<U, N>) const diff --git a/tests/vec_test.cpp b/tests/vec_test.cpp @@ -314,4 +314,18 @@ TEST(test_rebind) CHECK(v2[1] == 3); } +TEST(test_arg_access) +{ + univector<float> v1(10); + v1 = counter(); + auto e1 = std::move(v1) + 10; + std::get<0>(e1.args)[0] = 100; + std::get<1>(e1.args).val = 1; + univector<float, 10> v2 = e1; + CHECK(v2[0] == 101); + CHECK(v2[1] == 2); + CHECK(v2[2] == 3); + CHECK(v2[9] == 10); +} + int main(int argc, char** argv) { return testo::run_all("", true); }