Skip to content

Instantly share code, notes, and snippets.

@markpapadakis
Last active August 29, 2015 14:10
Show Gist options
  • Save markpapadakis/fc9a2dae1c115b3bfdb9 to your computer and use it in GitHub Desktop.
Save markpapadakis/fc9a2dae1c115b3bfdb9 to your computer and use it in GitHub Desktop.
template<typename T>
static inline constexpr T Max(void)
{
return std::numeric_limits<T>::is_signed ? (T)((((uint64_t)~0) >> (64 - (sizeof(T) * 8 - 1)))) : ((T)~0) - 1;
}
template<typename T>
static inline constexpr T Min(void)
{
return std::numeric_limits<T>::is_signed ? -Max<T>() : 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment