Skip to content

Instantly share code, notes, and snippets.

@ownwaterloo
Created December 23, 2010 12:53
Show Gist options
  • Save ownwaterloo/752932 to your computer and use it in GitHub Desktop.
Save ownwaterloo/752932 to your computer and use it in GitHub Desktop.
difference in character types
void f0(int x);
void f0(signed int x) {}
void f1(char x);
void f1(signed char x) {}
void f2(char x);
void f2(unsigned char x) {}
void f(char* pc, int* pi)
{
signed char* psc = pc;
unsigned char* puc = pc;
signed int* psi = pi;
}
template<typename T, typename >
struct is_same_type { enum { value = false}; };
template<typename T>
struct is_same_type<T,T> { enum { value = true}; };
typedef int assert1[!is_same_type<char, signed char>::value? 1:-1];
typedef int assert2[!is_same_type<char, unsigned char>::value? 1: -1];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment