So I'm curious if c++17 gives me the flexibility to do this. I have this answer which contains the code:
template <typename T>
function<void(vector<pair<T, T>>&)> vertex_triangle(const size_t index, const vector<pair<T, T>>& polygon) {
if (0U == index){
return [&](vector<pair<T, T>>& output){ output.push_back(polygon.back());
output.push_back(polygon.front());
output.push_back(polygon[1U]); };
}else if (index == (polygon.size() - 1U)){
return [&](vector<pair<T, T>>& output){ output.push_back(polygon[polygon.size() - 2U]);
output.push_back(polygon.back());
output.push_back(polygon.front()); };
}else{
return [&](vector<pair<T, T>>& output){ output.push_back(polygon[index - 1U]);
output.push_back(polygon[index]);
output.push_back(polygon[index + 1U]); };
}
}
I think that I should be able to change the function signature to: auto vertex_triangle(const size_t index, const vector<pair<T, T>>& polygon) thereby preserving closure type optimization. Additionally I'd really like to have my lambda parameter be auto& rather than vector<pair<T, T>>&.
Would c++17 support these changes?