C++0x

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Post Reply
User avatar
GroundUpEngine
Chaos Rift Devotee
Chaos Rift Devotee
Posts: 835
Joined: Sun Nov 08, 2009 2:01 pm
Current Project: mixture
Favorite Gaming Platforms: PC
Programming Language of Choice: C++
Location: UK

C++0x

Post by GroundUpEngine »

Does anybody use the new version of C++, I found myself inclined while I was recently learning some Java for the coming first year in uni. The reason I tried this new version of C++ was because of some of the features that are supported in Java that I remembered/realized were recently added to C++ in this late update.

"Range-based for-loop" from http://en.wikipedia.org/wiki/C%2B%2B11

Code: Select all

int my_array[5] = {1, 2, 3, 4, 5};
for (int &x : my_array) {
    x *= 2;
}
User avatar
Nokurn
Chaos Rift Regular
Chaos Rift Regular
Posts: 164
Joined: Mon Jan 31, 2011 12:08 pm
Favorite Gaming Platforms: PC, SNES, Dreamcast, PS2, N64
Programming Language of Choice: Proper C++
Location: Southern California
Contact:

Re: C++0x

Post by Nokurn »

I use C++11 extensively.
User avatar
bbguimaraes
Chaos Rift Junior
Chaos Rift Junior
Posts: 294
Joined: Wed Apr 11, 2012 4:34 pm
Programming Language of Choice: c++
Location: Brazil
Contact:

Re: C++0x

Post by bbguimaraes »

The only reason I wouldn't use it would be on code that should run on other platforms. It might take a while for those compilers to catch up with the new features. That aside, I use it constantly. I even compiled gcc when the version installed on Ubuntu didn't support it. Some of the features I remember using (I'll surely forget some):

Code: Select all

vector<int> f() {
    // User-types list initialization.
    vector<int> v = { 1, 2, 3, 4, 5 };
    return v;
}

// ...

// Move copy-constructor =).
vector v = f();

// Auto type and constant begin/end.
auto it = v.cbegin();

// Lambda functions, rarely (though I always have to google the damn syntax).
sort(v.begin(), v.end(), [](int x, int y) { return y < x; });

// The freaking string constructor for fstream.
ifstream reader(someStringThatCanFinallyBeUsedToWithoutCUnderlineStr);
I still have to take a look at the new things in the standard library.
Post Reply