Boost logo

Boost :

From: Goran Mitrovic (gmit_at_[hidden])
Date: 2004-09-21 04:30:55


Ben Hutchings <ben.hutchings <at> businesswebsoftware.com> writes:
> > I think I have found a better 'always-false' condition which
> > does not trigger a warning, and works at least in VC7.1:
> > do{ }while(__LINE__==-1)
> > Do you see a problem with this approach?
> <snip>
> It works in VC++ 7.1 if you enable "edit and continue", because
> this results in non-standard expansion of the __LINE__ macro to
> an expression that isn't a compile-time constant.
> In general it doesn't work.

Why not something like:

class aa {
public:
    operator bool() const {
        return false;
    }
};

do {} while(aa());

Optimizing this shouldn't be a problem for most compilers...


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