|
Boost : |
From: Greg Colvin (Gregory.Colvin_at_[hidden])
Date: 2002-12-17 15:34:13
At 09:47 AM 12/17/2002, you wrote:
>I hope it is permissible to ask a mp question.
>
>I'd like to have a template parameter is an int. If represents an
>arithmetic shift of an integral value. If the parameter is positive
>I'd like to shift left, and if negative shift right.
>
>Is it feasible to implement something like this? Any hints?
template <typename T, typename U> T shift(T val, U bits) {
if (bits > 0)
return val >> bits;
else if (bits < 0)
return val << -bits;
else
return val;
}
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk