Periodically I’ll stumble across a small but useful piece of code. I have a small list right now, but as I stumble across them, I’ll post them here. Note: I do not take credit for any of this code.
Pausing your application
1 |
__asm int 3; |
or
1 |
__debugbreak(); |
Convert any data type to a std::string object
1 2 3 4 5 6 7 8 |
#include <sstream> template <typename T> std::string toString( const T &arg ) { std::stringstream ss; ss << arg; return ss.str(); } |
Test if a float is zero or near zero
1 2 3 4 |
inline bool IsZero( float val ) { return( fabs( val ) < EPSILON); } |
EPSILON is a #define that is something small, like 0.002f
Note, I will repost, I just realized that serendipity can’t handle angle brackets…