我为此搜索了 c++ 模拟(python):
sorted(vector, key=lambda x : my_function(x))
Run Code Online (Sandbox Code Playgroud)
当然还有构造:
std::sort(vector.begin(), vector.end(), [](const auto& lhs, const auto& rhs) {
return my_function(lhs) < my_function(rhs);
});
Run Code Online (Sandbox Code Playgroud)
我只是想知道是否存在单参数构造。