本文整理匯總了C++中dependent::at方法的典型用法代碼示例。如果您正苦於以下問題:C++ dependent::at方法的具體用法?C++ dependent::at怎麽用?C++ dependent::at使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類dependent
的用法示例。
在下文中一共展示了dependent::at方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: f
void f() {
int Sum = 0;
for (int I = 0, E = V.size(); I < E; ++I) {
printf("Fibonacci number is %d\n", V[I]);
Sum += V[I] + 2;
}
// CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
// CHECK-FIXES: for (int Elem : V)
// CHECK-FIXES-NEXT: printf("Fibonacci number is %d\n", Elem);
// CHECK-FIXES-NEXT: Sum += Elem + 2;
for (int I = 0, E = V.size(); I < E; ++I) {
printf("Fibonacci number is %d\n", V.at(I));
Sum += V.at(I) + 2;
}
// CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
// CHECK-FIXES: for (int Elem : V)
// CHECK-FIXES-NEXT: printf("Fibonacci number is %d\n", Elem);
// CHECK-FIXES-NEXT: Sum += Elem + 2;
for (int I = 0, E = Pv->size(); I < E; ++I) {
printf("Fibonacci number is %d\n", Pv->at(I));
Sum += Pv->at(I) + 2;
}
// CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
// CHECK-FIXES: for (int Elem : *Pv)
// CHECK-FIXES-NEXT: printf("Fibonacci number is %d\n", Elem);
// CHECK-FIXES-NEXT: Sum += Elem + 2;
// This test will fail if size() isn't called repeatedly, since it
// returns unsigned int, and 0 is deduced to be signed int.
// FIXME: Insert the necessary explicit conversion, or write out the types
// explicitly.
for (int I = 0; I < Pv->size(); ++I) {
printf("Fibonacci number is %d\n", (*Pv).at(I));
Sum += (*Pv)[I] + 2;
}
// CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
// CHECK-FIXES: for (int Elem : *Pv)
// CHECK-FIXES-NEXT: printf("Fibonacci number is %d\n", Elem);
// CHECK-FIXES-NEXT: Sum += Elem + 2;
for (int I = 0; I < Cv->size(); ++I) {
printf("Fibonacci number is %d\n", Cv->at(I));
Sum += Cv->at(I) + 2;
}
// CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
// CHECK-FIXES: for (int Elem : *Cv)
// CHECK-FIXES-NEXT: printf("Fibonacci number is %d\n", Elem);
// CHECK-FIXES-NEXT: Sum += Elem + 2;
}
示例2: f
void f() {
int sum = 0;
for (int i = 0, e = v.size(); i < e; ++i) {
printf("Fibonacci number is %d\n", v[i]);
sum += v[i] + 2;
}
// CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
// CHECK-FIXES: for (auto & elem : v)
// CHECK-FIXES-NEXT: printf("Fibonacci number is %d\n", elem);
// CHECK-FIXES-NEXT: sum += elem + 2;
for (int i = 0, e = v.size(); i < e; ++i) {
printf("Fibonacci number is %d\n", v.at(i));
sum += v.at(i) + 2;
}
// CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
// CHECK-FIXES: for (auto & elem : v)
// CHECK-FIXES-NEXT: printf("Fibonacci number is %d\n", elem);
// CHECK-FIXES-NEXT: sum += elem + 2;
for (int i = 0, e = pv->size(); i < e; ++i) {
printf("Fibonacci number is %d\n", pv->at(i));
sum += pv->at(i) + 2;
}
// CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
// CHECK-FIXES: for (auto & elem : *pv)
// CHECK-FIXES-NEXT: printf("Fibonacci number is %d\n", elem);
// CHECK-FIXES-NEXT: sum += elem + 2;
// This test will fail if size() isn't called repeatedly, since it
// returns unsigned int, and 0 is deduced to be signed int.
// FIXME: Insert the necessary explicit conversion, or write out the types
// explicitly.
for (int i = 0; i < pv->size(); ++i) {
printf("Fibonacci number is %d\n", (*pv).at(i));
sum += (*pv)[i] + 2;
}
// CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
// CHECK-FIXES: for (auto & elem : *pv)
// CHECK-FIXES-NEXT: printf("Fibonacci number is %d\n", elem);
// CHECK-FIXES-NEXT: sum += elem + 2;
for (int i = 0; i < cv->size(); ++i) {
printf("Fibonacci number is %d\n", cv->at(i));
sum += cv->at(i) + 2;
}
// CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
// CHECK-FIXES: for (auto & elem : *cv)
// CHECK-FIXES-NEXT: printf("Fibonacci number is %d\n", elem);
// CHECK-FIXES-NEXT: sum += elem + 2;
}
示例3: constness
// Ensure that 'const auto &' is used with containers of non-trivial types.
void constness() {
int Sum = 0;
for (int I = 0, E = Constv.size(); I < E; ++I) {
printf("Fibonacci number is %d\n", Constv[I].X);
Sum += Constv[I].X + 2;
}
// CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
// CHECK-FIXES: for (const auto & Elem : Constv)
// CHECK-FIXES-NEXT: printf("Fibonacci number is %d\n", Elem.X);
// CHECK-FIXES-NEXT: Sum += Elem.X + 2;
for (int I = 0, E = Constv.size(); I < E; ++I) {
printf("Fibonacci number is %d\n", Constv.at(I).X);
Sum += Constv.at(I).X + 2;
}
// CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
// CHECK-FIXES: for (const auto & Elem : Constv)
// CHECK-FIXES-NEXT: printf("Fibonacci number is %d\n", Elem.X);
// CHECK-FIXES-NEXT: Sum += Elem.X + 2;
for (int I = 0, E = Pconstv->size(); I < E; ++I) {
printf("Fibonacci number is %d\n", Pconstv->at(I).X);
Sum += Pconstv->at(I).X + 2;
}
// CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
// CHECK-FIXES: for (const auto & Elem : *Pconstv)
// CHECK-FIXES-NEXT: printf("Fibonacci number is %d\n", Elem.X);
// CHECK-FIXES-NEXT: Sum += Elem.X + 2;
// This test will fail if size() isn't called repeatedly, since it
// returns unsigned int, and 0 is deduced to be signed int.
// FIXME: Insert the necessary explicit conversion, or write out the types
// explicitly.
for (int I = 0; I < Pconstv->size(); ++I) {
printf("Fibonacci number is %d\n", (*Pconstv).at(I).X);
Sum += (*Pconstv)[I].X + 2;
}
// CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
// CHECK-FIXES: for (const auto & Elem : *Pconstv)
// CHECK-FIXES-NEXT: printf("Fibonacci number is %d\n", Elem.X);
// CHECK-FIXES-NEXT: Sum += Elem.X + 2;
}