
Paul Mensonides wrote:
The only way to "have-your-cake-and eat-it-too" in the presence of macros like min/max is to prevent them from expanding manually with BOOST_PREVENT_MACRO_SUBSTITUTION.
int main() { using std::min; min BOOST_PREVENT_MACRO_SUBSTITUTION(1, 2); return 0; }
This yields ADL and local context (which includes std::min if necessary).
Thanks, Paul. That's correct. boost::std_min is defined as follows: template< typename T > inline T const & std_min( T const & a, T const & b ) { using std::min; return min BOOST_PREVENT_MACRO_SUBSTITUTION ( a, b ); } So a call to boost::std_min is essentially an unqualified call to min, with a using directive to pull in std::min. Since it's an unqualified call, ADL can also pull in additional overloads from different namespaces. boost::std_min is nothing more than a convenience to keep you from littering your code with using statements and Ugly Macros. I might hazard to make a generalization here and suggest you prefer std_min to std::min because (a) chances are good you want ADL anyway, (b) std_min doesn't suffer from macro mish-mash, and (c) std_min is 1 fewer character to type when you're already in the boost namespace. :-) Hope that makes sense now. -- Eric Niebler Boost Consulting www.boost-consulting.com