[ create a new paste ] login | about

Link: http://codepad.org/TK0GhhAe    [ raw code | fork ]

k06a - C++, pasted on Nov 4:
template<typename T>
struct param
{
   T n;
   param(T t) : n(t) {}
};

template<typename T>
param<T> f(T n)
{
   T a = (1&(n^(n>>1)));
   n ^= (a ? 0xAA : 0x55);
   return param<T>(n);
}

template<typename T>
T f(param<T> n)
{
   return f(n.n).n + 1;
}

int main()
{
   for(int i = -127; i <= 127; i++)
   {
      char c = i;
      if (-c != f(f(c)))
         printf("%d != %d\n", c, f(f(c)));
   };
}


Output:
No errors or program output.


Create a new paste based on this one


Comments: