5 Replies - 2872 Views - Last Post: 12 December 2010 - 11:14 PM Rate Topic: -----

#1 ishkabible  Icon User is offline

  • spelling expret
  • member icon





Reputation: 1616
  • View blog
  • Posts: 5,707
  • Joined: 03-August 09

c++0x new for loop

Posted 12 December 2010 - 09:01 PM

ok so i was reading some stuff on Wikipedia about c++0x (maybe it's bad info) and i was messing around with it but for some reason or another i can't figure out the syntax for the new for each loops. here is my little test program, everything but the loop compiles just fine.

#include <iostream>
#include <deque>

using namespace std;

int main() {
    deque<int> test = {0,1,2,3,4,5,6,7,8,9,10};
    for (auto x: test) {
		cout<<x;
    }
    return 0;
}


This post has been edited by ishkabible: 12 December 2010 - 09:03 PM


Is This A Good Question/Topic? 0
  • +

Replies To: c++0x new for loop

#2 Oler1s  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1395
  • View blog
  • Posts: 3,884
  • Joined: 04-June 09

Re: c++0x new for loop

Posted 12 December 2010 - 10:24 PM

What compiler (and version, specifically) are you using?

This post has been edited by Oler1s: 12 December 2010 - 10:24 PM

Was This Post Helpful? 1
  • +
  • -

#3 jimblumberg  Icon User is online

  • member icon


Reputation: 3845
  • View blog
  • Posts: 11,735
  • Joined: 25-December 09

Re: c++0x new for loop

Posted 12 December 2010 - 10:25 PM

I found this link for each. It might explain it a little better.

Jim
Was This Post Helpful? 0
  • +
  • -

#4 Salem_c  Icon User is offline

  • void main'ers are DOOMED
  • member icon

Reputation: 1574
  • View blog
  • Posts: 2,996
  • Joined: 30-May 10

Re: c++0x new for loop

Posted 12 December 2010 - 10:30 PM

Have you read the documentation for your compiler to see if it currently implements "the auto loop feature of c++0x" ?

Because writing a few words on wiki doesn't magically transform all compilers to actually WORK.
Was This Post Helpful? 1
  • +
  • -

#5 Oler1s  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1395
  • View blog
  • Posts: 3,884
  • Joined: 04-June 09

Re: c++0x new for loop

Posted 12 December 2010 - 10:31 PM

That's not it, jimblumberg. You just linked to a VC++ extension. OP refers to range based for loop.
Was This Post Helpful? 1
  • +
  • -

#6 ishkabible  Icon User is offline

  • spelling expret
  • member icon





Reputation: 1616
  • View blog
  • Posts: 5,707
  • Joined: 03-August 09

Re: c++0x new for loop

Posted 12 December 2010 - 11:14 PM

it's gnu g++ 4.4, ill check to see what features of c++0x it supports and check back.

edit: yep that's the issue, i need 4.6 for range based for loop. 4.4 dosn't even cite it as being supported or not. 4.5 cites it as being unsupported 4.6 cites it as supported.

edit2: and 4.6 has not been released yet so i guess i don't get to use range based for loops until 4.6 is released :( thanks!!

This post has been edited by ishkabible: 12 December 2010 - 11:21 PM

Was This Post Helpful? 1
  • +
  • -

Page 1 of 1