
On Thu, Jan 15, 2009 at 9:12 AM, Phil Endecott < spam_from_boost_dev@chezphil.org> wrote:
you need to define a rightshift functor that does. How about:
struct rightshift { some_integer_type operator()(const fixed &x, unsigned offset) { return x.impl >> offset; } };
This is not performing a right shift on the fixed value itself but rather on the integer that it uses as its implementation. Hence my preference for another name. Maybe you consider this too subtle to worry about. Maybe it is.
It is not performing a right shift on the object, only on the underlying data, but if the class did support casting to an integer, then its >> operator would suffice. So, it is a replacement for an arithmetic right shift, and the the user may write it any way they want that provides an even division by two which is rounded consistently. It is also critical that this method be fast as it is used in multiple loops of the integer_sort algorithm, so the user should be encouraged to use a fast operator (not division). Can you think of a better name for this than rightshift?