This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [Patch] libstdc++/29989
Doug Gregor wrote:
On Dec 4, 2006, at 1:02 PM, Paolo Carlini wrote:
Doug Gregor wrote:
<windows.h> is known to #define min and max as macros.
Interesting, thanks. Then, what do you suggest? Should we undef min
and max elsewhere too? The PR was about <limits>, which, at some
point in the far past also had undefs, not anymore...
In Boost, we do backflips to avoid the problem without #undef'ing min
or max. We have a macro like this:
#define BOOST_PREVENT_MACRO_SUBSTITUTION
To use min or max in the library, we write, e.g.,
min BOOST_PREVENT_MACRO_SUBSTITUTION (x, y)
FWIW, we simply parenthesize the names:
template <class T, class Compare>
const T& (min)(const T&, const T&, Compare);
template <class T>
const T& (min)(const T &a, const T &b) {
return (min)(a, b, less<T>());
}
Martin