|
Boost : |
From: Beman Dawes (beman_at_[hidden])
Date: 1999-12-10 12:06:52
At 08:53 AM 12/10/99 -0600, Ed Brey wrote:
>8. const rational operator++(int)
> {
> rational was(*this);
> operator++();
> return was;
> }
>
>Clever variable naming in the use of "was". I really like it.
>BTW, the postfix operators tend to always be boring code (except for
>creative variable names) that ends up just making a temporary and
>calling the prefix version. Is there any way to add this to
>operators.hpp?
The pending update to operators.hpp from Jeremy Siek and Dave
Abrahams adds:
template <class T>
struct incrementable
{
friend T operator++(T& x, int)
{
T tmp(x);
++x;
return tmp;
}
};
template <class T>
struct decrementable
{
friend T operator--(T& x, int)
{
T tmp(x);
--x;
return tmp;
}
};
That update will be posted as soon as we can get a test program to
compile with a certain notorious compiler (or give up on it!).
--Beman
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk