C++11 Inferring "auto" type fails for "vector" [message #997443] |
Mon, 07 January 2013 14:34 |
Programmist Setevik Messages: 12 Registered: January 2013 |
Junior Member |
|
|
With "-std=c++11" added to discovery, CDT Juno fails to figure out "auto" type for vectors, while it works fine for other containers, from arrays to sets to maps etc:
Simple program below (create a C++ Project). Hover over auto's to see how the "i"s type if properly inferred, except for vector<>. The template param doesn't make difference, vector<int> or vector<string>
gcc++ 4.7.2, Juno SR1 (updating to latest nightly doesn't help). The program itself compiles fine.
Just a minor annoyance - since CDT doesn't know the proper type for the auto variable, things like code completion etc, won't work.
//////////////////////////////////////////////////////
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <string>
using namespace std;
int main() {
vector<string> v;
set<string> s;
map<string, int> m;
string sa[10];
for (auto i: v) {
cout << i;
}
for (auto i: sa) {
cout << i;
}
for (auto i: s) {
cout << i;
}
for (auto i: m) {
cout << i.first;
}
}
[Updated on: Mon, 07 January 2013 15:39] Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.02824 seconds