
I have ripped out the std_min/std_max functions. They were a less-than-perfect solution to the problems caused by the min/max macros defined by some platform headers. I have fixed all the places in the Boost affected by this change, and I have also updated the coding guidelines. For your references, the guidelines are reproduced here: Make sure your code compiles in the presence of the min() and max() macros. Some platform headers define min() and max() macros which cause some common C++ constructs to fail to compile. Some simple tricks can protect your code from inappropriate macro substitution: If you want to call std::min() or std::max(): If you do not require argument-dependent look-up, use (std::min)(a,b). If you do require argument-dependent look-up, you should: #include <boost/minmax.hpp> Use BOOST_USING_STD_MIN(); to bring std::min() into the current scope. Use min BOOST_PREVENT_MACRO_SUBSTITUTION (a,b); to make an argument-dependent call to min(a,b). If you want to call std::numeric_limits<int>::max(), use (std::numeric_limits<int>::max)() instead. If you want to call a min() or max() member function, instead to doing obj.min(), use (obj.min)(). If you want to declare or define a function or a member function named min or max, then you must use the BOOST_PREVENT_MACRO_SUBSTITUTION macro. Instead of writing int min() { return 0; } you should write int min BOOST_PREVENT_MACRO_SUBSTITUTION () { return 0; } This is true regardless if the function is a free (namespace scope) function, a member function or a static member function, and it applies for the function declaration as well as the function definition. Thanks. -- Eric Niebler Boost Consulting www.boost-consulting.com

Eric Niebler wrote:
I have ripped out the std_min/std_max functions. They were a less-than-perfect solution to the problems caused by the min/max macros defined by some platform headers. I have fixed all the places in the Boost affected by this change, and I have also updated the coding guidelines.
Ehm... the guidelines are a bit contrived. Why did you decide to kill the definitions in minmax.hpp? - Volodya

Vladimir Prus <ghost@cs.msu.su> writes:
Eric Niebler wrote:
I have ripped out the std_min/std_max functions. They were a less-than-perfect solution to the problems caused by the min/max macros defined by some platform headers. I have fixed all the places in the Boost affected by this change, and I have also updated the coding guidelines.
Ehm... the guidelines are a bit contrived. Why did you decide to kill the definitions in minmax.hpp?
There are several substantial threads about why the old definitions didn't work. http://news.gmane.org/find-root.php?message_id=%3cmemo.828774%40cix.compulin... http://news.gmane.org/find-root.php?message_id=%3c40D72DA7.3040500%40boost%2... -- Dave Abrahams Boost Consulting http://www.boost-consulting.com

David Abrahams wrote:
Ehm... the guidelines are a bit contrived. Why did you decide to kill the definitions in minmax.hpp?
There are several substantial threads about why the old definitions didn't work.
http://news.gmane.org/find-root.php?message_id=%3cmemo.828774%40cix.compuli nk.co.uk%3e http://news.gmane.org/find-root.php?message_id=%3c40D72DA7.3040500%40boost% 2dconsulting.com%3e
I'm still at loss. Why minmax.hpp can't just undef macroses? And the guidelines Eric posted are pretty complex for "I want ADL" case. Why that can't be wrapped in a function? And really, what was the problem with the current minmax.hpp, except that it did not work on gcc-2.95-stlport? - Volodya

Vladimir Prus <ghost@cs.msu.su> writes:
David Abrahams wrote:
Ehm... the guidelines are a bit contrived. Why did you decide to kill the definitions in minmax.hpp?
There are several substantial threads about why the old definitions didn't work.
http://news.gmane.org/find-root.php?message_id=%3cmemo.828774%40cix.compuli nk.co.uk%3e http://news.gmane.org/find-root.php?message_id=%3c40D72DA7.3040500%40boost% 2dconsulting.com%3e
I'm still at loss. Why minmax.hpp can't just undef macroses?
Because people want to use boost libraries with other libraries that depend on those macros.
And the guidelines Eric posted are pretty complex for "I want ADL" case. Why that can't be wrapped in a function?
And really, what was the problem with the current minmax.hpp, except that it did not work on gcc-2.95-stlport?
Did you read all the threads? -- Dave Abrahams Boost Consulting http://www.boost-consulting.com
participants (3)
-
David Abrahams
-
Eric Niebler
-
Vladimir Prus