So lets say that I have a function like: pair<int, int> func() and a vector<int> vec. I want to do this:
vec.resize(size(vec) + 2U);
tie(*next(rbegin(vec)), *rbegin(vec)) = func();
I just feel like this is a really complicated way to write what I'm doing. Is there a way to accomplish this without the resize call and all that?
You might use structured bindings (C++17) and
push_backinstead:That's definitely way easier to read.