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;
   }


_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Reply via email to