type trait for detecting unsigned integer

Is there a way to detect a unsigned integer? I would like to have a template to replace a macro that checks a value is in a range. Here is what I have so far: template <typename Limit_Type> static inline void in_range ( boost::uint32_t value, Limit_Type limit ) { if ( value > limit ) { throw errors::Internal_Exception ( errors::Internal_Exception::INVALID_VALUE ); } } I would like to replace the "boost::uint32_t" with a default typename and check to see if the 'value' is an unsigned type. Stephen

Stephen Torri wrote:
Is there a way to detect a unsigned integer? I would like to have a template to replace a macro that checks a value is in a range. Here is what I have so far:
template <typename Limit_Type> static inline void in_range ( boost::uint32_t value, Limit_Type limit ) { if ( value > limit ) { throw errors::Internal_Exception ( errors::Internal_Exception::INVALID_VALUE ); } }
I would like to replace the "boost::uint32_t" with a default typename and check to see if the 'value' is an unsigned type.
See boost/type_traits/is_signed.hpp Jeff Flinn
participants (3)
-
Jeff Flinn
-
John Maddock
-
Stephen Torri