Is there any shortcut to convert from std::vector<T>to std::vector<T*>or to std::vector<T&>?
Essentially I want to replace:
std::vector<T> source;
std::vector<T*> target;
for(auto it = source.begin(); it != source.end(); it++)
{
target.push_back(&(*it));
}
with one line.
To provide some context: I have one set of functions that perform their calculations on std::vector<Polygon>, and some of them require std::vector<Polygon*>. Therefore, I need to convert back and forth a couple of times, because the interface of these functions should not change.
source
share