Boost logo

Boost :

Subject: Re: [boost] Proposed templated integer_sort
From: Phil Endecott (spam_from_boost_dev_at_[hidden])
Date: 2009-01-15 12:12:17


Steven Ross wrote:
> On Wed, Jan 14, 2009 at 2:48 PM, Phil Endecott wrote:
>> I still believe that "rightshift" is the wrong name for this functor in
>> these cases.
>
> It's an arithmetic right shift, or alternatively division by a power of 2.

No, not in general, e.g.:

>> class fixed {
>> ....
>> some_integer_type impl;
>> ....
>> bool operator<(const fixed& other) const;
>> fixed operator>>(unsigned int shift_mt) const;
>> };
>>
>> What do I need to do?

> 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.

Phil.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk