Linked by Hadrien Grasland on Wed 15th Jun 2011 07:32 UTC, submitted by ebasconp
General Development "The recently finished C++ ISO standard, with the working name of C++0x, is due to be published this summer, following the finishing touches to the ISO spec language and standards wonks agreed upon in March."
Thread beginning with comment 477276
To view parent comment, click here.
To read all comments associated with this story, please click here.
RE[3]: Basically, awesome
by ebasconp on Wed 15th Jun 2011 15:14 UTC in reply to "RE[2]: Basically, awesome"
ebasconp
Member since:
2006-05-09

I too would like to see a much simplified C++ design, instead of even more features added with few things removed.


A lot of features have been added having simplicity as main feature; for example: "auto" and "range-based" for.

For example, to show all items in a vector, in current ISO C++ you need to do something like:

template <typename T>
void show(const vector<T>& v)
{
for (typename vector<T>::const_iterator i =
v.begin(); i != v.end(); i++)
cout << *i << endl;
}

In the new C++0x you can do also this stuff:

template <typename T>
void show(const vector<T>& v)
{
for (auto i = v.begin(); i != v.end(); i++)
cout << *i << endl;
}

or using the range-based loop:

template <typename T>
void show(const vector<T>& v)
{
for (auto& x : v)
cout << i << endl;
}

IMHO, simple, beautiful and powerful because they are new features, but they add simplicity too.

Reply Parent Score: 3

RE[4]: Basically, awesome
by Neolander on Wed 15th Jun 2011 15:33 in reply to "RE[3]: Basically, awesome"
Neolander Member since:
2010-03-08

While you can totally see it from this point of view, I see it myself at something which makes C++ compilers more difficult to implement, and as such probably less efficient in each individual area ;)

Reply Parent Score: 1

RE[4]: Basically, awesome
by Veto on Thu 16th Jun 2011 09:53 in reply to "RE[3]: Basically, awesome"
Veto Member since:
2010-11-13

for (auto i = v.begin(); i != v.end(); i++)


In the educative example above, you should really use ++i instead of i++. This may seem like nitpicking, but there is a significant performance difference. When using i++, the compiler will have to invoke the copy constructor at each iteration.

Reply Parent Score: 2

RE[5]: Basically, awesome
by dnebdal on Thu 16th Jun 2011 10:01 in reply to "RE[4]: Basically, awesome"
dnebdal Member since:
2008-08-27

"for (auto i = v.begin(); i != v.end(); i++)


In the educative example above, you should really use ++i instead of i++. This may seem like nitpicking, but there is a significant performance difference. When using i++, the compiler will have to invoke the copy constructor at each iteration.
"

I thought most modern compilers were smart enough to recognize that you're not using the unincremented value, and thus do the right thing?

Reply Parent Score: 1