jeudi 3 novembre 2016

Pointer to template method of template class within a template function

Is there a way to make the commented definition of b working?

template <typename t0>
struct comp_impl
{
        t0 g;

        template <typename t1>
        t0 h(t1 x)
        {
                return g;
        };
};

template <typename t0, typename t1>
void foo()
{
//      WORKS
        int (comp_impl<int>::*a)(int) = &comp_impl<int>::h<int>;
//      FAILS
//      t0 (comp_impl<t0>::*b)(t1) = &comp_impl<t0>::h<t1>;
}

void bar()
{
        foo<int, int>();
}

Aucun commentaire:

Enregistrer un commentaire