Re: [Boost-bugs] [Boost C++ Libraries] #3270: Ambiguous conversion, even though no conversion exists

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #3270: Ambiguous conversion, even though no conversion exists
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2009-07-17 16:20:55


#3270: Ambiguous conversion, even though no conversion exists
-------------------------------------------------+--------------------------
 Reporter: Olaf Lenz <lenzo@…> | Owner: dgregor
     Type: Bugs | Status: new
Milestone: Boost 1.40.0 | Component: function
  Version: Boost 1.39.0 | Severity: Problem
 Keywords: |
-------------------------------------------------+--------------------------

Comment(by steven_watanabe):

 Replying to [ticket:3270 Olaf Lenz <lenzo@…>]:
> Unfortunately,
> in this case, there does not even exist a conversion from "class A" to
 the
> function type! To test that, just comment the first definition of
 B::f():


 Any type can be converted to a boost::function.
 The declaration of the conversion always exists,
 which is all that the compiler checks for in overload
 resolution. The conversion doesn't compile unless
 the type has a function call operator.

> I think that this can be considered a bug. Or what else can I do in this
 case?

 Did you really intend to make the overload for A const
 and the overload for boost::function non-const?

 The following compiles for me

 {{{
 #include <boost/function.hpp>

 struct A {};

 struct B {
   void f(const A &a) const {}
   void f(boost::function< void () > a) const {}
 };

 int main() {
   A a;
   B b;
   b.f(a);
 }

 }}}

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/3270#comment:1>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:00 UTC