21 #ifndef __MIA_TOOLS_HH 22 #define __MIA_TOOLS_HH 1 56 std::list<std::string>& result;
57 const std::string pattern;
63 FSearchFiles(std::list<std::string>& __result,
const std::string& __pattern);
66 void operator()(
const std::string& path);
91 template <
typename T,
bool is_
float>
94 static T apply(
double x) {
100 struct __round<T, false> {
101 static T apply(
double x) {
102 return static_cast<T
>(rint(x));
117 template <
typename T>
120 const bool is_floating_point = std::is_floating_point<T>::value;
121 return __round<T, is_floating_point>::apply(x);
130 template <
typename T,
bool is_
float>
131 struct __round_clamped {
133 static T apply(
double x) {
139 struct __round_clamped<float, true> {
141 static float apply(
double x) {
142 double y = x < std::numeric_limits<float>::max() ?
143 ( x > -std::numeric_limits<float>::max() ? x : -std::numeric_limits<float>::max()) :
144 std::numeric_limits<float>::max();
145 return static_cast<float>(y);
150 struct __round_clamped<bool, false> {
151 static float apply(
double x) {
157 template <
typename T>
158 struct __round_clamped<T, false> {
159 static T apply(
double x) {
160 const double y = rint(x);
161 const double yy = y < std::numeric_limits<T>::max() ?
162 ( y > std::numeric_limits<T>::min() ? y : std::numeric_limits<T>::min()) :
163 std::numeric_limits<T>::max();
164 return static_cast<T
>(yy);
179 template <
typename T>
182 const bool is_floating_point = std::is_floating_point<T>::value;
183 return __round_clamped<T, is_floating_point>::apply(x);
187 inline void eat_char( std::istream& is,
char expect_val,
const char *message)
191 if ( c != expect_val)
192 throw std::runtime_error(message);
T mia_round_clamped(double x)
void EXPORT_CORE sincos(double x, double *sin, double *cos)
#define NS_MIA_BEGIN
conveniance define to start the mia namespace
A Scope based helper class to save and restore the current working directory.
#define EXPORT_CORE
Macro to manage Visual C++ style dllimport/dllexport.
void EXPORT_CORE sincosf(float x, float *sin, float *cos)
void eat_char(std::istream &is, char expect_val, const char *message)
#define NS_MIA_END
conveniance define to end the mia namespace