Tim
Tim

Reputation: 99398

determine value range of template type in C++

In a template function, I like to determine the range for the value of its template type. For specific type, like int, INT_MAX and INT_MIN are what I want. But how to do the same for a template type?

Thanks and regards!

Upvotes: 0

Views: 437

Answers (3)

sellibitze
sellibitze

Reputation: 28087

See the <limits> header and std::numeric_limits

Upvotes: 0

Jeff Hardy
Jeff Hardy

Reputation: 7662

For numeric types, you can use the std::numeric_limits class template in the <limits> header.

Upvotes: 2

fa.
fa.

Reputation: 2486

This is done with type traits like those from boost

Upvotes: 0

Related Questions