From: John Maddock (john_at_[hidden])
Date: 2005-11-05 11:39:17


The following short program works fine for VC7.1, but for several well
regarded compilers including Intel-8/9 and gcc-3.4 fails to compile due to
"ambiguous overload" errors. It's causing errors in the TR1/Bind concept
tests, and I'd like to figure out if it's the compiler or Boost.Bind that's
at fault so I can file defect reports with the compiler vendors if
necessary.

Here's the test case:

#include <boost/bind.hpp>

template <class Functor>
void consume(Functor f);

double test_proc(int a, char b, long c)
{
   return a+b+c;
}
struct from_double
{
   from_double(double){}
};
int main()
{
   consume(boost::bind<double>(&test_proc, 0, 0, 0));
   consume(boost::bind<float>(&test_proc, 0, 0, 0));
   consume(boost::bind<long double>(&test_proc, 0, 0, 0));
   consume(boost::bind<from_double>(&test_proc, 0, 0, 0));
}

And a typical error message from Intel-9 is:

$ icl -GX -c -Ic:\\data\\boost\\develop\\boost bind.cpp
Intel(R) C++ Compiler for 32-bit applications, Version 9.0 Build
20050912Z Pa
ckage ID: W_CC_C_9.0.024
Copyright (C) 1985-2005 Intel Corporation. All rights reserved.
30 DAY EVALUATION LICENSE

bind.cpp
bind.cpp(21): error: more than one instance of overloaded function
"boost::bind"
 matches the argument list:
            function template "boost::bind<R,F,A1,A2,A3>(F, A1, A2, A3)"
            function template "boost::bind(R (*)(B1, B2, B3), A1, A2, A3)"
            argument types are: (double (*)(int, char, long), int, int, int)
     consume(boost::bind<double>(&test_proc, 0, 0, 0));
             ^

compilation aborted for bind.cpp (code 2)

Note that it's the presence of the function pointer overloads that causes
the error: in other words it's an artefact of the implementation that causes
the error, not the TR1 specification itself.

Anyone any ideas whose at fault here?

Thanks,

John.