Can I avoid "shift count is negative" warning? (involves template parameter)

Phil Endecott spam_from_gcc_help@chezphil.org
Thu May 3 21:42:00 GMT 2007


jlh wrote:
> template <int a>
> int shift (int b)
> {
> 	if (a > 0) {
> 		unsigned ua = a;
> 		return b >> ua;
> 	} else {
> 		unsigned ua = -a;
> 		return b << ua;
> 	}
> }
> template int shift<1>(int);
> template int shift<-1>(int);


Thanks, that works!

Phil.






More information about the Gcc-help mailing list