13 template<
bool B,
typename T,
typename F>
14 struct __if__ {
using type = T; };
15 template<
typename T,
typename F>
16 struct __if__<false, T, F> {
using type = F; };
29 template<
bool B,
typename T,
typename F>
30 using _if_ =
typename __if__<B,T,F>::type;
35 template<
typename T>
struct __no_ref__ {
typedef T type; };
36 template<
typename T>
struct __no_ref__<T&> {
typedef T type; };
37 template<
typename T>
struct __no_ref__<T&&> {
typedef T type; };
62 template<
unsigned int C>
64 _if_< C<256,
unsigned char,
84 _no_ref_<T>&& _move_(T& arg)
91 constexpr const T& min(
const T& first,
const T& second)
93 return first<second ? first : second;
96 template<
typename T,
typename... Arguments>
97 constexpr const T& min(
const T& first,
const Arguments& ...args)
99 return min(first, min(args...));
104 constexpr const T& max(
const T& first,
const T& second)
106 return first>second ? first : second;
109 template<
typename T,
typename... Arguments>
110 constexpr const T& max(
const T& first,
const Arguments& ...args)
112 return max(first, max(args...));
117 constexpr void swap(T& first, T& second)
_if_< C< 256, unsigned char, _if_< C< 65536, unsigned short, unsigned int > > uint_best_fit
Chooses the smallest unsigned integer type that fits a constant.
Definition: templates.hpp:66
_no_ref_< T > && _move_(T &&arg)
Creates rvalue reference from object (useful in move semantics)
Definition: templates.hpp:78
typename __no_ref__< T >::type _no_ref_
gets rid of type reference
Definition: templates.hpp:51
typename __if__< B, T, F >::type _if_
Decides type based on a boolean expression.
Definition: templates.hpp:30