I believe I understand the concept of perfect forwarding in C++. But I'm missing something similar for "this". Let's have:
class X {
std::vector<int> vec;
public:
std::vector<int> const &getVec() const & { return vec; }
std::vector<int> & getVec() & { return vec; }
std::vector<int> getVec() && { return std::move(vec); }
};
As std::forward() compresses similar definitions for parameters, I'd like to have something similar for "this". Something like:
class X {
std::vector<int> vec;
public:
auto &&getVec() /*???const &*/ { return thisForward(vec); }
};
Is something like the above possible (or available in STL or boost)? Or, at least, is there some workaround?
Plus an additional question (just for verification), does my 3 overloads of getVec() above make a sense? Is it okay (for optimization reasons) to have such 3 overloads? (Assume "X" is a container-like class.)