c++0x is (finally) finalized

Kirby

Lifer
Apr 10, 2006
12,028
2
0
So did they basically incorporate a few Boost libraries?

Threading FTW too.
 

Cogman

Lifer
Sep 19, 2000
10,286
145
106
So did they basically incorporate a few Boost libraries?

Threading FTW too.

Added a few libraries, some small changes to how the language behaves (auto, rvalue, ect), and a few niceties (such as proper handling of unicode characters).

http://en.wikipedia.org/wiki/C%2B+0x

Also has for loops that are more compact. they are akin to foreach loops in other languages.
 
Last edited:

BoberFett

Lifer
Oct 9, 1999
37,562
9
81
http://cplusplus-soup.com/2011/03/28/c0x-will-be-c-2011/

Wow, that took long enough.

I'm actually looking forward to the auto variable type. Looks like it could be pretty useful for the lazy (especially when using iterators).

That, and the thread library is pretty interesting to me.

Ugh, the variant. While it can be used properly by good coders who don't make assumptions about data, I've had to fix enough shoddy code with bugs introduced by weakly typed variables for a lifetime.
 

Markbnj

Elite Member <br>Moderator Emeritus
Moderator
Sep 16, 2005
15,682
14
81
www.markbetz.net
Ugh, the variant. While it can be used properly by good coders who don't make assumptions about data, I've had to fix enough shoddy code with bugs introduced by weakly typed variables for a lifetime.

Boy do I ever agree with this statement.

I don't mind...

var myList = new List<something>();

I do mind...

var myThingy = ReturnSomethingCompletelyUnknown();

Thank the lord for intellisense.
 

Mark R

Diamond Member
Oct 9, 1999
8,513
16
81
Ugh, the variant. While it can be used properly by good coders who don't make assumptions about data, I've had to fix enough shoddy code with bugs introduced by weakly typed variables for a lifetime.

No. Auto is not a variant!

Auto is a fixed strong-type - however, it avoids the programmer having to specify the type in those cases where the type can be determined by the compiler.

e.g.
Code:
string [] mystrings = GetListOfStrings();
auto name = mystrings[0];

name = 1.0f;

will be pre-processed to
Code:
string [] mystrings = GetListOfStrings();

string name = mystrings[0];
name = 1.0f;

while will fail to compile because a float cannot be assigned to a strongly-typed string.
 

Cogman

Lifer
Sep 19, 2000
10,286
145
106
Boy do I ever agree with this statement.

I don't mind...

var myList = new List<something>();

I do mind...

var myThingy = ReturnSomethingCompletelyUnknown();

Thank the lord for intellisense.

What it avoids (which I think is a good thing) is instead of typing something like

SuperLongNamespace::SuperLongClassName::SuperLongClassType varname = SuperLongClassName::function();

It doesn't allow variable type reassigning. Still strongly typed, just now you don't have to know the exact type you are assigning.
 

Markbnj

Elite Member <br>Moderator Emeritus
Moderator
Sep 16, 2005
15,682
14
81
www.markbetz.net
What it avoids (which I think is a good thing) is instead of typing something like

SuperLongNamespace::SuperLongClassName::SuperLongClassType varname = SuperLongClassName::function();

It doesn't allow variable type reassigning. Still strongly typed, just now you don't have to know the exact type you are assigning.

Agreed. All I'm saying is that I like to be able to read a declaration and know the type of the thing being declared, without having to navigate to a method definition or hover for the signature to see what it returns.
 

Cogman

Lifer
Sep 19, 2000
10,286
145
106
Agreed. All I'm saying is that I like to be able to read a declaration and know the type of the thing being declared, without having to navigate to a method definition or hover for the signature to see what it returns.

True. And I guess it could add some confusion to what is going on since you have to be somewhat familiar with the code to know what is going on with different variables.

I wonder, could you do this

Code:
auto function(auto vara, auto varb)
{
   return vara + varb;
}

Because, honestly, that would eliminate most of the uses of templates.
 

BoberFett

Lifer
Oct 9, 1999
37,562
9
81
True. And I guess it could add some confusion to what is going on since you have to be somewhat familiar with the code to know what is going on with different variables.

I guess I don't see the benefit. It may save a few keystrokes, but I prefer explicit code. Ambiguity makes for maintenance nightmares.

Also, I could see it causing issues with derived classes that may look similar due to usage at a glance, but have different functionality. I suppose I just have PTSD brought on by years of fixing horrible code by lazy programmers.
 
Last edited:

Absolution75

Senior member
Dec 3, 2007
983
3
81
True. And I guess it could add some confusion to what is going on since you have to be somewhat familiar with the code to know what is going on with different variables.

I wonder, could you do this

Code:
auto function(auto vara, auto varb)
{
   return vara + varb;
}

Because, honestly, that would eliminate most of the uses of templates.
Auto can't be a return type or a parameter type
 

JasonCoder

Golden Member
Feb 23, 2005
1,893
1
81
Doesn't most of this stuff come from interoperability stories? Variants and IDispatch based interfaces came about to support scripting (typeless) clients. If you're not supporting that, you never need to deal with it.

Sort of like why would you do COM if you owned all the endpoints of an app. Think masturbating with a cheese grater... slightly amusing but mostly just painful.

If it's not a variant, then it's dynamic is the way I read it.