dimanche 15 décembre 2019

error: reference to overloaded function could not be resolved

The following code:

struct A
{
    using this_t = A;
    template <class F1>
    void ins(const F1& fu)
    {
    }
    template <class F1, class... Args>
    void ins(const F1& fu, const Args&... args)
    {
        this_t::ins<Args...>(args...);
        // the line which is causing the error:
        constexpr decltype(&this_t::ins<Args...>) func = &this_t::ins<Args...>;
    }
};
int main()
{
    A a;
    a.ins(5, 5, 5, 5, 5);
}

Gives this error:

error: reference to overloaded function could not be resolved

As shown here: https://godbolt.org/z/nJiY4A

What's going wrong here and how is it possible to get the pointer to the function then?

Aucun commentaire:

Enregistrer un commentaire