I have:
struct vec {
__m128 m128;
inline vec(__m128 m128) : m128(m128) {
}
}
so now __m128
can implicitly convert to vec
, but when I use it, as in:
void doStuff(vec &v) { *stuff be doing* }
doStuff( _mm_set1_ps(1.0f)); //mm_set_ps returns __m128
I get an error saying:
Can't convert from __m128 to &vec
so what's the problem and how to fix it?
doStuff
takes in a reference to a non-const vec
. Non-const references cannot bind to rvalues like the result of a function call.
If you need to modify v
inside doStuff
, then store the result of _mm_set1_ps(1.0f)
in an intermediate variable, then call with that:
vec v = _mm_set1_ps(1.0f);
doStuff(v);
If you don't need to modify v
, change doStuff
to take its argument by reference-to-const:
void doStuff(const vec &v) { /*stuff doing*/ }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With