https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61368

            Bug ID: 61368
           Summary: Sfinae with template member
           Product: gcc
           Version: 4.8.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: p.bartosiewi at partner dot samsung.com

GCC 4.8.2 can't compile following reduced code snippet, but I think the code is
fine. I've checked it against clang 3.4 and code compiles fine. 

------------------------
typedef char true_type;
typedef int false_type;

struct SubObject {
    template<class V>
    void visit(V v) {
        v(1); // error here
    }
};

struct Object {
    template<class V>
    void visit(V v) {
        v(SubObject());
    }
};

struct VisitorMatcher {
    template <typename T>
    void operator()(T);
};

template <typename T>
struct hasVisitor {
    template <typename C>
    static true_type test(decltype(&C::template visit<VisitorMatcher()>));
    //template <typename C>
    //static true_type test(decltype(&C::template visit<int>));
    template <typename C> static false_type test(...);
    typedef decltype(test<T>(0)) type;
};

struct Visitor {
    template<class T>
    void operator()(T v)
    {
        typedef typename hasVisitor<T>::type type;
        // impl(v, type());
    }
};

int main()
{
    Object o;
    o.visit(Visitor());
}

Reply via email to