
Guillaume Melquiond wrote:
Is the interval library the only Boost library allowing min and max functions to be used with user-defined types? How is this problem dealt with in the other libraries.
Most of the boost librarys makes qualified calls to min/max, as in std::min(a,b), and so do not use Koenig lookup. I don't think you should change anything, though. ADL is working for you and your users, and I don't want to muck that up.
And the regression test with VC7.1 didn't expose this problem. (Shortcoming of vc7.1 or the interval regression tests?)
Yes it is a shortcoming of the interval regression tests (that doesn't mean it isn't also a shortcoming of VC7.1). I only test for things that could break in the current code, not for things somebody else could change afterward :-).
IMO, I think you should add a test for this. It's a valid usage scenario which you support. You (and I, as a maintainer) want to know when it breaks.
Wasn't there the idea of adding prefix and suffix headers to Boost? If it was undef'd or pragma_push'd for all the libraries, it would avoid changing these 800 occurrences. Or am I missing something?
Not all compilers support push_macro/pop_macro, and unconditionally removing users' macros is impolite, considering there are ways we can make boost code impervious to these macros.
Another thought just occured to me. Consider:
#define BOOST_EMPTY template< class T > void f(T const &a, T const &b) { using std::min; min BOOST_EMPTY (a,b); }
This seems to be enough to prevent min() macro substitution, and it would preserve ADL. I checked with VC6, VC7.1, gcc (cygwin) and with Comeau Online, and they all like it. Will this work on other compilers too?
It's ugly. But I suppose we could use a boost_min macro to avoid cluttering the code (if it still works).
I agree it's ugly. But not as ugly as the current solution in win32.hpp, which can silently change the meaning of users' code. You don't need a boost_min macro -- you can define your own interval_min/interval_max templates as follows: #define BOOST_EMPTY template< class T > inline void interval_min(T const &a, T const &b) { using std::min; min BOOST_EMPTY (a,b); } and now use interval_min instead of min everywhere. Perhaps we can do this once and call it boost_min, so everybody can use it. Opinions? -- Eric Niebler Boost Consulting www.boost-consulting.com