Basing on discussions with Jason, I'm filing this PR, distilled from a typical
library-only implementation of std::is_convertible instantiated with D and A,
where A is an ambiguous base of D.

As a matter of fact, I'm personally not *completely* sure that SFINAE should
apply here, but I'm tempted to believe than for is_convertible one cannot do
much better than the below at the library-only level - I just checked that
boost::is_convertible behaves exactly the same. In any case, better double
checking with Jason:

struct A { };

struct B
: public A { };

struct C
: public A { };

struct D
: public B, public C { };

template<typename _From, typename _To>
  class mini_is_convertible
  {
    typedef char __one;
    typedef struct { char __arr[2]; } __two;

    static __one __test(_To);
    static __two __test(...);

  public:
    static const bool __value = sizeof(__test(_From())) == 1;
};

void foo()
{
  mini_is_convertible<D, A>::__value;
}


-- 
           Summary: Problem with SFINAE and ambiguous base
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: paolo dot carlini at oracle dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44896

Reply via email to