我们总是写:
public static final int A = 0;
Run Code Online (Sandbox Code Playgroud)
题:
static final声明常量的唯一方法吗? public final int A = 0;,A仍然是一个常量或只是一个实例字段? 我有来自这里的代码:
std::sort(begin(v), end(v), [](auto const &t1, auto const &t2) {
return get<0>(t1) < get<0>(t2); // or use a custom compare function
});
Run Code Online (Sandbox Code Playgroud)
我想多次排序元组,所以我编写了这段代码:
int k = 10;
while(k--){
std::sort(begin(v), end(v), [](auto const &t1, auto const &t2) {
return get<k>(t1) < get<k>(t2); // or use a custom compare function
});
}
Run Code Online (Sandbox Code Playgroud)
但我得到错误error: ‘k’ is not captured.我试着这样做:
int k = 10;
while(k--){
std::sort(begin(v), end(v), [&k](auto const &t1, auto const &t2) {
return get<k>(t1) < get<k>(t2); // or use …Run Code Online (Sandbox Code Playgroud)