lundi 24 octobre 2016

How to perfect-forward this?

Is there a way to write a "perfect forwarding member function" that will perfect forward this? E.g. like this:

struct AA
{
    template < typename Callable >
    void ff(Callable&& callable) /*auto&& ??*/
    { std::invoke(std::forward<Callable>(callable), *this); }
};

Now I have to make ff a global function, like this:

template < typename AA, typename Callable >
void globalff(AA&& aa, Callable&& callable)
{
    std::invoke(std::forward<Callable>(callable), std::forward<AA>(aa));
}

Aucun commentaire:

Enregistrer un commentaire