You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
FWIW, we've been using a C++ template for map() on Teensy for quite some time. It turned to be quite a bit more complicated than the code above. Ultimately we ended up with 2 templates using type_traits and std:enable_if. When the input "x" is any integer type, you want to convert all 5 inputs to signed long. If you skip that step, problems with numerical range come up. When the input "x" is any floating point type, you want to convert the other 4 inputs to that type, so the whole thing is done in the same numerical precision as the input number.
Another problem that comes up is the min() and max() macros conflict with C++ min() and max(), which come along with including type_traits. Ultimately 2 versions of min & max were needed, depending on whether compiling C or C++.
Hello !
Apologies if this is a duplicate, but I couldn't find any previous discussions on github about it.
Is there a reason why map() isn't templated to provide maximum awesomeness??
Something as simple as this, would get rid of surprises when trying to use map() to scale to [0,1]:
The text was updated successfully, but these errors were encountered: