I am checking numeric value range with type traits, and unsigned types generate warning.
Comparison of unsigned expression >= 0 is always true
How to disable some warning at specific code range? I used GCC style #pragma
with Clang but this doesn't work.
Here's my code.
template<typename originT, typename destinationT>
void
assertForNumericRange(const originT value)
{
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wtype-limits"
assertWithReason(value >= std::numeric_limits<destinationT>::min());
assertWithReason(value <= std::numeric_limits<destinationT>::max());
#pragma GCC diagnostic pop
}
Note
Currently, I divided the assertion into three groups, floating-point, unsigned int, signed int. But I wish to integrate them into one if possible.
I am using Xcode 5.0 beta. In command-line, it reports this: Apple LLVM version
5.0 (clang-500.1.58) (based on LLVM 3.3svn)
Target: x86_64-apple-darwin12.3.0
Thread model: posix