C++11 (aka C++0x) officially approved

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
TheBuzzSaw
Chaos Rift Junior
Chaos Rift Junior
Posts: 310
Joined: Wed Dec 02, 2009 3:55 pm
Current Project: Paroxysm
Favorite Gaming Platforms: PC
Programming Language of Choice: C++
Contact:

C++11 (aka C++0x) officially approved

Post by TheBuzzSaw »

http://www.phoronix.com/scan.php?page=n ... &px=OTc4OA

I didn't pay a ton of attention to this while it was developing. I mostly skimmed over the wiki page and thought, "Hmm, that'd be nice. Oh well." Well, it actually got approved! GCC has already implemented large chunks of it. I guess it is safe to start learning now. :P

Thoughts on this? I'm fairly excited. I hope the native thread support is actually good. :)
User avatar
Kyosaur
Chaos Rift Cool Newbie
Chaos Rift Cool Newbie
Posts: 78
Joined: Tue Jul 13, 2010 2:00 am
Favorite Gaming Platforms: PS2,PS3,NDS
Programming Language of Choice: C++

Re: C++11 (aka C++0x) officially approved

Post by Kyosaur »

TheBuzzSaw wrote:http://www.phoronix.com/scan.php?page=n ... &px=OTc4OA

I didn't pay a ton of attention to this while it was developing. I mostly skimmed over the wiki page and thought, "Hmm, that'd be nice. Oh well." Well, it actually got approved! GCC has already implemented large chunks of it. I guess it is safe to start learning now. :P

Thoughts on this? I'm fairly excited. I hope the native thread support is actually good. :)
Is it sad that i dont care and am not excited for this new standard?
Image
User avatar
TheBuzzSaw
Chaos Rift Junior
Chaos Rift Junior
Posts: 310
Joined: Wed Dec 02, 2009 3:55 pm
Current Project: Paroxysm
Favorite Gaming Platforms: PC
Programming Language of Choice: C++
Contact:

Re: C++11 (aka C++0x) officially approved

Post by TheBuzzSaw »

Psh. Go back to your C#, heathen!
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++11 (aka C++0x) officially approved

Post by Nokurn »

I am fucking stoked for this. I was seriously considering porting my engine to GCC 4.7 just to get an early run with the new features.
  • The changes to initialization are a pleasure to work with.
  • The new for-loop syntax is wonderful for some more lengthy types, ie:

    Code: Select all

    for (std::map<uint, std::vector<uint>>::const_iterator it = items.begin(); it != items.end(); ++it)
    vs:

    Code: Select all

    for (auto const& curr : items)
  • Lambda functions are quite nice for simplifying code where you're repeating yourself a lot but don't necessarily need an entirely new function.
  • Constructor delegation is something I've been wanting for a while (I don't like creating regular functions to share code between constructors).
  • The changes to member initialization are very nice as well.
  • I quite like the changes to enumerations, especially enums being their own namespaces. That will improve readability a lot, IMO.
  • I was excited for unrestricted unions, until I messed around with them a bit and found that my Vector*D classes are still not considered simple enough to be included in a union. Still no hope for improving the organization of my Event class without sacrificing memory. :(
  • Explicitly declared default constructors will help me resolve some ambiguity in my code. Deleted functions will be nice, too.
  • STL threads are going to let me cut out some of the code I've written for doing cross-platform threading (I don't use things like Boost).
  • STL regular expressions! These are going to be nice for doing quick bits of parsing that don't really warrant the inclusion of a whole 'nother library just for regex.
  • STL random numbers will effectively eliminate the need for my MT19937 implementation and the supporting uniform distribution code.
These are just the reasons that I personally like C++11, though. I feel like it's going to make my code a lot more readable, a lot more concise, better organized, and add some features that I've thought STL has been lacking for some time now.
User avatar
Kyosaur
Chaos Rift Cool Newbie
Chaos Rift Cool Newbie
Posts: 78
Joined: Tue Jul 13, 2010 2:00 am
Favorite Gaming Platforms: PS2,PS3,NDS
Programming Language of Choice: C++

Re: C++11 (aka C++0x) officially approved

Post by Kyosaur »

TheBuzzSaw wrote:Psh. Go back to your C#, heathen!
lol im not a C# coder. Im just not excited for this new standard really. I know i probably SHOULD be, but its just whatever to me - nothing jumps out and excites me (i'll of course learn though).
Image
User avatar
MadPumpkin
Chaos Rift Maniac
Chaos Rift Maniac
Posts: 484
Joined: Fri Feb 13, 2009 4:48 pm
Current Project: Octopia
Favorite Gaming Platforms: PS1-3, Genesis, Dreamcast, SNES, PC
Programming Language of Choice: C/++,Java,Py,LUA,XML
Location: C:\\United States of America\Utah\West Valley City\Neighborhood\House\Computer Desk

Re: C++11 (aka C++0x) officially approved

Post by MadPumpkin »

:D hash tables <3

EDIT: I was just reading through a bunch of it, skimming the rest. It looks like 50-50 on features I'm excited for, versus not/don't care much. I love the new random generator and many other things though. Looks great I never would have known so thanks for the link.
Last edited by MadPumpkin on Tue Aug 16, 2011 12:02 am, edited 1 time in total.
While Jesus equipped with angels, the Devil's equipped with cops
For God so loved the world that he blessed the thugs with rock
Image
Image
Image
Rapid Cube
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 22
Joined: Mon Mar 14, 2011 11:43 pm
Programming Language of Choice: C++

Re: C++11 (aka C++0x) officially approved

Post by Rapid Cube »

Does anyone know of a better explanation of how lambda expressions work than the one on Wikipedia?
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++11 (aka C++0x) officially approved

Post by Nokurn »

Rapid Cube wrote:Does anyone know of a better explanation of how lambda expressions work than the one on Wikipedia?
I might be of assistance, if you were to describe exactly what you need more information on.
User avatar
ismetteren
Chaos Rift Junior
Chaos Rift Junior
Posts: 276
Joined: Mon Jul 21, 2008 4:13 pm

Re: C++11 (aka C++0x) officially approved

Post by ismetteren »

Rapid Cube wrote:Does anyone know of a better explanation of how lambda expressions work than the one on Wikipedia?
They are just functions without a name. You often use them to pass to functions that take other functions. (higer order functions). I don't really know if this explanation is better though.. ;)
Image ImageImage Image
Rapid Cube
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 22
Joined: Mon Mar 14, 2011 11:43 pm
Programming Language of Choice: C++

Re: C++11 (aka C++0x) officially approved

Post by Rapid Cube »

ismetteren wrote:
Rapid Cube wrote:Does anyone know of a better explanation of how lambda expressions work than the one on Wikipedia?
They are just functions without a name. You often use them to pass to functions that take other functions. (higer order functions). I don't really know if this explanation is better though.. ;)
I understand the basic concept, its just the syntax that confuses me.
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++11 (aka C++0x) officially approved

Post by Nokurn »

A lambda function is declared in three parts:
  • Closures - These are variables that you want to be present in the lambda at all times. Consider closures as being like... defining the local scope for the lambda function. These exact variables will always be present in every call to the lambda, unlike parameters, which must be passed every time.
    Closures are placed at the beginning of the lambda declaration, within braces, in a comma-separated list. Variables without prefixes are passed into the lambda by value, meaning that a copy of the variable is created just for the lambda. Variables prefixed by an ampersand (&) are passed into the lambda by reference, so that what you get is a reference to the variable rather than a copy. If an equal sign without a variable is given as a closure, all variables that aren't explicitly named in the closure will be passed to the lambda by value. Likewise, an ampersand without a variable will cause the same effect, but passing the variables by reference.
  • Parameters - If I need to explain this part, you shouldn't be thinking about lambdas yet. :lol:
  • Return type - This functions largely the same way as specifying the return type of a function, with two exceptions: it comes after the parameters, and it isn't always necessary. If you have an extremely simple lambda, ie. "return something;", you can omit the type declaration, and the compiler will use its fancy new type inference to decide what the function's type should be.
So it goes like this:

Code: Select all

[closures](parameters) -> type { code }
Or if you want to use type inference,

Code: Select all

[closures](parameters) { code }
I think that Wikipedia sufficiently explains the specifics of storing a lambda function, so I won't write about that unless you need it explained as well.
Hope this clears some things up.
User avatar
Falco Girgis
Elysian Shadows Team
Elysian Shadows Team
Posts: 10294
Joined: Thu May 20, 2004 2:04 pm
Current Project: Elysian Shadows
Favorite Gaming Platforms: Dreamcast, SNES, NES
Programming Language of Choice: C/++
Location: Studio Vorbis, AL
Contact:

Re: C++11 (aka C++0x) officially approved

Post by Falco Girgis »

Nothing really excites me either, just because I spend all of my time at work and play on embedded platforms whose compilers will probably never support these features.

It's almost worthless to me, to be honest.
qpHalcy0n
Respected Programmer
Respected Programmer
Posts: 387
Joined: Fri Dec 19, 2008 3:33 pm
Location: Dallas
Contact:

Re: C++11 (aka C++0x) officially approved

Post by qpHalcy0n »

It's one of those things that language acolytes get wet over.

...It will take years to a decade or never before it sees any widespread usage in the industry.
Post Reply