Possible Duplicate:
C++ variable types limits
I have a defined type that may not stay at what it is. I want to make use of the maximum value for that type as an undefined value but don't want to use something like, INT_MAX because I might later change the type to a long or something else entirely. I've seen a template way of doing this but now cannot find it. How in a tempated safe way can i find the maximum allowable value for a type?
Use:
std::numeric_limits<T>::max()
It's in the header <limits>
. See here:
http://www.cplusplus.com/reference/std/limits/numeric_limits/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With