kfrlib / kfr

Fast, modern C++ DSP framework, FFT, Sample Rate Conversion, FIR/IIR/Biquad Filters (SSE, AVX, AVX-512, ARM NEON)
https://www.kfrlib.com
GNU General Public License v2.0
1.66k stars 253 forks source link

expression combination mechanism selects the wrong overload #171

Closed jcelerier closed 1 year ago

jcelerier commented 1 year ago

Very simply put:

double y = kfr::sine(0.5);

and

  double x;
  double y = kfr::sine(x);

fails to compile as the selected overload is

template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>)>
KFR_FUNCTION expression_function<fn::sine, E1> sine(E1&& x)
{
    return { std::forward<E1>(x) };
}

instead of

template <typename T1, KFR_ENABLE_IF(is_numeric<T1>)>
KFR_FUNCTION T1 sine(const T1& x)
{
    return intrinsics::sine(x);
}

the only one that works is with a const ref:

  const double x;
  double y = kfr::sine(x);
dancazarin commented 1 year ago

Fixed in dev branch