cgv
Loading...
Searching...
No Matches
min.h
1#pragma once
2
3#include <climits>
4#include <float.h>
5
6namespace cgv {
7 namespace type {
8 namespace traits {
11 template <typename T> struct min {};
12 template <> struct min<char> { static const char value = CHAR_MIN; };
13 template <> struct min<short> { static const short value = SHRT_MIN; };
14 template <> struct min<int> { static const int value = INT_MIN; };
15 template <> struct min<long> { static const long value = LONG_MIN; };
16 template <> struct min<unsigned char> { static const unsigned char value = 0; };
17 template <> struct min<unsigned short> { static const unsigned short value = 0; };
18 template <> struct min<unsigned int> { static const unsigned int value = 0; };
19 template <> struct min<unsigned long> { static const unsigned long value = 0; };
20
23 template <typename T> struct min_fct { static T get_value() { return min<T>::value; } };
24 template <> struct min_fct<float> { static float get_value() { return -FLT_MAX; } };
25 template <> struct min_fct<double> { static double get_value() { return -DBL_MAX; } };
26 }
27 }
28}
the cgv namespace
Definition print.h:11
the min_fct traits provides a static function returning the minimal value of a type.
Definition min.h:23
the min traits defines for each type in the static const member value, what the minimum value is.
Definition min.h:11