Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » C++11 Inferring "auto" type fails for "vector"
C++11 Inferring "auto" type fails for "vector" [message #997443] Mon, 07 January 2013 14:34 Go to next message
Programmist Setevik is currently offline 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

Re: C++11 Inferring "auto" type fails for "vector" [message #998178 is a reply to message #997443] Wed, 09 January 2013 14:06 Go to previous message
Programmist Setevik is currently offline Programmist Setevik
Messages: 12
Registered: January 2013
Junior Member
OK,

the issue seems to have been fixed as of yesterday's nightly build. Applied it on 2 different PCs and both now correctly infer the "auto" declared variable.

Specify this repository: http://download.eclipse.org/tools/cdt/builds/juno/nightly and update
Previous Topic:how eclipse synchronizes its views?
Next Topic:Getting Started
Goto Forum:
  


Current Time: Thu Sep 18 15:48:43 GMT 2014

Powered by FUDForum. Page generated in 0.02993 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software