I have the following class which stores a perfectly forwarded reference to a function:
template <class F>
class Visitor
{
public:
Visitor(F &&f) : _f(std::forward<F>(f))
{
}
xt::LOOP_CONTROL OnElem(xvi::Elem &elem)
{
return _f(elem);
// or should it be:
// return std::forward<F>(_f)(elem);
}
private:
F &&_f;
};
Wondering if it makes a difference to call _f(elem) or std::forward<F>(_f)(elem);?
Lambda cannot have ref qualified
operator ()currently, so for them, both forms are equivalent.For custom functor, it might differ with
std::forward<F>(_f)(elem);: