Shortest C \ C++ function to generate -1, 0 ,1

40

f(i,j){return~-(2434352710>>8*i+2*j&3);}

A hackish 35 solution (xxd dump):

0000000: 6628 692c 6a29 7b72 6574 7572 6e7e 2d28  f(i,j){return~-(
0000010: 695b 2246 4619 9122 5d3e 3e32 2a6a 2633  i["FF.."]>>2*j&3
0000020: 293b 7d                                  );}

If proper octal escapes are used, it's the same 40 characters:

f(i,j){return~-(i["FF\31\221"]>>2*j&3);}

C99, 34

f(i,j){return(i<3?1-j+i/2:j-2)%2;}

32

f(i,j){return~-(j+2-i*i/3&3)%2;}