Hello Matthew Towler!

Matthew Towler schrieb:

> > Recently we tried to compile the boost 1.29 with some of our older Win32
> > codes using the .NET 7.0
> > compiler. We got an compiler error due to ambiguities of these overloads
> > inside the CMap template
> > implementation header <afxtempl.h>.
> In VC6 the std::min and std::max templates were not present, so they are
> often added manually (and probably in boost).
> In VC7 these functions were put in the standard headers where they
> should be, so any manually added versions cause problems.  A tested
> solution that will work across both is:


Thanks for your reply, but maybe we (I?) misunderstand each other (you?).
Actually I know of that very bad VC6 behaviour, but I think, that the mentioned
code example

#include <boost/config.hpp>
#include <afxtempl.h>

int main()
 CMap<int, int&, __int64, __int64&> theMap;

should work for both VC6 and VC7, doesn't it?

The problem is the following: Either by personal #inclusion or indirectly #included
by other boost files we #include <boost/config.hpp>. Some MFC headers following
this inclusion (like <afxtempl.h>) *do* rely on the corresponding macro's, so I think,
that the intend of the win32.hpp file is to provide the corresponding overload 
This can be deduced from comments like the following: (Start at row 54 of file 

"#ifdef BOOST_MSVC
namespace std{
  // Apparently, something in the Microsoft libraries requires the "long"
  // overload, because it calls the min/max functions with arguments of
  // slightly different type.  (If this proves to be incorrect, this
  // whole "BOOST_MSVC" section can be removed.)
  inline long min(long __a, long __b) {
    return __b < __a ? __b : __a;

The above mentioned min/max functions are all normal functions and should have
higher priority than the normale min/max templates. Under VC6 they do their work
properly, but under VC7 we observe those ambuigities, I mentioned.

To my opinion, under VC7 the above mentioned #ifdef BOOST_MSVC should NOT
be activated, instead of this there should be an #include of <algorithm> (later 
the existing "using std::min"/"using std::max"), which should provide the necessary
min/max instances.

Or did I misunderstand something?


Daniel Spangenberg

Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Reply via email to