[mpl][type_traits] Getting the minimum and maximum value for a buit-in type at compile time

I would have thought that there must be a way to get the minimum and maximum value for a C++ built-in type but my search through mpl and type_traits yields nothing and numeric_limits requires a run-time function call. Surely this information is available to the compiler so it must be available to the TMP programmer somewhere. Where is it ?

I would have thought that there must be a way to get the minimum and maximum value for a C++ built-in type but my search through mpl and type_traits yields nothing and numeric_limits requires a run-time function call.
integer_traits is available (http://www.boost.org/doc/libs/1_41_0/libs/integer/integer_traits.html) and provides const_min and const_max, but it sounds like you're after non-integer traits information. I don't know how to get compile-time constants for floating point types. - Rhys

Rhys Ulerich wrote:
I would have thought that there must be a way to get the minimum and maximum value for a C++ built-in type but my search through mpl and type_traits yields nothing and numeric_limits requires a run-time function call.
integer_traits is available (http://www.boost.org/doc/libs/1_41_0/libs/integer/integer_traits.html) and provides const_min and const_max, but it sounds like you're after non-integer traits information. I don't know how to get compile-time constants for floating point types.
That's what I needed. Thanks !

I would have thought that there must be a way to get the minimum and maximum value for a C++ built-in type but my search through mpl and type_traits yields nothing and numeric_limits requires a run-time function call.
integer_traits is available (http://www.boost.org/doc/libs/1_41_0/libs/integer/integer_traits.html) and provides const_min and const_max, but it sounds like you're after non-integer traits information. I don't know how to get compile-time constants for floating point types.
That would be impossible within the language, floating point values can't be compile time constants. John.

I would have thought that there must be a way to get the minimum and maximum value for a C++ built-in type but my search through mpl and type_traits yields nothing and numeric_limits requires a run-time function call. Surely this information is available to the compiler so it must be available to the TMP programmer somewhere. Where is it ?
boost/integer_traits.hpp part of Boost.Integer. HTH, John.
participants (3)
-
Edward Diener
-
John Maddock
-
Rhys Ulerich