|
Boost : |
From: Eric Niebler (eric_at_[hidden])
Date: 2006-07-24 16:41:22
Daryle Walker wrote:
> On 7/10/06 1:24 PM, "Eric Niebler" <eric_at_[hidden]> wrote:
>
> [SNIP problem of making a macro like MAX(a, b) == ((a)<(b)?(b):(a)) except
> that it evaluates its arguments only once, but still works on arguments of
> different types and maintains the arguments' const and l/r-value states.]
>> Is there interest in turning this into a BOOST_MIN/BOOST_MAX library?
> [TRUNCATE the actual code]
>
> Yes, please.
BOOST_MIN() and BOOST_MAX() now live in minmax_macro.zip at:
http://boost-consulting.com/vault/index.php?directory=Algorithms
and also in boost-sandbox CVS at boost/algorithm/minmax_macro.hpp. It's
been tested with gcc 3.x and msvc 7.1, and I took a stab at a version
for Comeau, but which is currently untested.
This code pokes into C++'s dark, dusty corners, and no two compilers
seem to agree, so any feedback/workarounds for other compilers is much
appreciated.
Thanks go to Howard Hinnant for feedback and test cases.
-- Eric Niebler Boost Consulting www.boost-consulting.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk