RosettaCodeData/Task/Even-or-odd/C++/even-or-odd-2.cpp

18 lines
290 B
C++
Raw Permalink Normal View History

2015-11-18 06:14:39 +00:00
template < typename T >
constexpr inline bool isEven( const T& v )
{
return isEven( int( v ) );
}
template <>
constexpr inline bool isEven< int >( const int& v )
{
return (v & 1) == 0;
}
template < typename T >
constexpr inline bool isOdd( const T& v )
{
return !isEven(v);
}