-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathutils.h
More file actions
38 lines (32 loc) · 713 Bytes
/
utils.h
File metadata and controls
38 lines (32 loc) · 713 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#pragma once
#include <cstdlib>
template <typename T>
inline T clamp(const T& value, const T& low, const T& high) {
return value < low ? low : (value > high ? high : value);
}
template<typename T>
inline int round(T d) {
return floor(d + 0.5);
}
class LBDebug {
public :
LBDebug(){}
LBDebug(const LBDebug &){}
~LBDebug(){
std::cout << oss.str() << std::endl;
}
template<typename T>
inline LBDebug & operator << ( const T & rhs) {
oss << rhs ;
oss << ' ' ;
return (* this) ;
}
private :
std::ostringstream oss;
};
inline LBDebug info() {
return LBDebug();
}
inline float rand_float() {
return float(rand()) / float(RAND_MAX);
}