File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -379,6 +379,19 @@ complex_t<Scalar> rotateRight(NBL_CONST_REF_ARG(complex_t<Scalar>) value)
379
379
return retVal;
380
380
}
381
381
382
+ // Annoyed at having to write a lot of boilerplate to do a select
383
+ // Essentially returns what you'd expect from doing `condition ? a : b`
384
+ template<typename Scalar>
385
+ complex_t<Scalar> ternaryOperator (bool condition, NBL_CONST_REF_ARG (complex_t<Scalar>) a, NBL_CONST_REF_ARG (complex_t<Scalar>) b)
386
+ {
387
+ const vector <Scalar, 2 > aVector = vector <Scalar, 2 >(a.real (), a.imag ());
388
+ const vector <Scalar, 2 > bVector = vector <Scalar, 2 >(b.real (), b.imag ());
389
+ const vector <Scalar, 2 > resultVector = condition ? aVector : bVector;
390
+ const complex_t<Scalar> result = { resultVector.x, resultVector.y };
391
+ return result;
392
+ }
393
+
394
+
382
395
}
383
396
}
384
397
You can’t perform that action at this time.
0 commit comments