I posted this answer that contains the code:
template <typename T>
auto vertex_triangle(const size_t index, const vector<pair<T, T>>& polygon) {
const auto& first = index == 0U ? polygon.back() : polygon[index - 1U];
const auto& second = polygon[index];
const auto& third = index == size(polygon) - 1U ? polygon.front() : polygon[index + 1U];
return [&](auto& output){ output.push_back(first);
output.push_back(second);
output.push_back(third); };
}
I thought that first
, second
and third
can really be used as lambda identifiers, such as:
[first = index == 0U ? polygon.back() : polygon[index - 1U],
second = polygon[index],
third = index == size(polygon) - 1U ? polygon.front() : polygon[index + 1U]](auto& output){ output.push_back(first);
output.push_back(second);
output.push_back(third); };
But I only want to fix the permalink. Without specifying the type in the identifier, how can I do this?
source
share