#include <iostream> using namespace std; template<typename T> T diff(T a, T b) { static_assert(std::is_signed<T>::value); return a-b; } int main() { diff<int>(3,2); diff<unsigned char> (1,2); return 0; }
Standard input is empty
prog.cpp: In instantiation of ‘T diff(T, T) [with T = unsigned char]’: prog.cpp:14:26: required from here prog.cpp:7:2: error: static assertion failed static_assert(std::is_signed<T>::value); ^~~~~~~~~~~~~
Standard output is empty