I am a newbie in programming. Recently I try to use the sorting function from c++ sort keeping track of indices
template <typename T>
std::vector<size_t> ordered(std::vector<T> const& values) {
std::vector<size_t> indices(values.size());
std::iota(begin(indices), end(indices), static_cast<size_t>(0));
std::sort(
begin(indices), end(indices),
[&](size_t a, size_t b) { return values[a] < values[b]; }
);
return indices;
}
In Xcode, it is successfully compiled without any warnings. While in g++, it shows the following error message:
error: expected expression
[&](size_t a, size_t b) { return values[a] < values[b];}
^
What does it imply? Thanks!