?

Log in

 

C++0x - Advanced C++ Community

About C++0x

Previous Entry C++0x Apr. 10th, 2006 @ 10:58 pm Next Entry
What's your opinion of the new stuff coming down the pike from the standards committee? Specifically, what do you think of Concepts? For those of you who are unfamiliar with some of the new things arriving in your next C++ standard, here is a brief summary.

Discuss.
Leave a comment
[User Picture Icon]
From:cbradfield
Date:April 11th, 2006 06:06 am (UTC)
(Link)
So, to answer my own post with my own opinion, I think what concepts allow for is great, but I think it is going to be a tad frustrating to write them. That is, it's another complicated feature that will the novice if they actually have to maintain custom concepts written by other developers. For example, I'm really digging that I can write the following:
std::vector<int> v;
sort(v);  // much simpler to read and understand!
Other advantages include more specific compiler error messages which will lower the barrier of entry to the language. I also dig the static initializers and the template typedefs.
[User Picture Icon]
From:notofthisworld
Date:April 11th, 2006 10:22 am (UTC)
(Link)
The rvalue-references make my head hurt. I understand them, but I think the rules could be difficult to describe to newcomers.

I can see why they're useful, of course, but I can't help thinking that references could be a lot simpler if they could all be redesigned from scratch.

Template typedefs are long overdue. Not having them hampers my code already.
[User Picture Icon]
From:xil
Date:April 11th, 2006 01:59 pm (UTC)
(Link)
I'm really excited about move operators. I can't wait to be able to do:

vector myfunction();

vector v;
v = myfunction();


And not have to worry about the cost of copying.


Also the stand library extensions look good. I've been using boost::shared_ptr quite a bit lately, it'll be nice to have that supported by the standard. I just hope they add at least one more round of libraries to it; they've added 10 so far, but if we have to wait another 10 years for another revision, it'd be nice if they added even more.
[User Picture Icon]
From:xil
Date:April 11th, 2006 02:00 pm (UTC)
(Link)
grr, meant to hit preview so I could do the whole <> replacement. Oh well, you get the idea.
[User Picture Icon]
From:cbradfield
Date:April 11th, 2006 05:46 pm (UTC)
(Link)
Yeah, this is really long-overdue. Sure, it is syntactic sugar, but sometimes a little sugar helps the medicine go down.

I actually use Loki::SmartPtr as I find Loki a little less bulky than dealing with Boost. I'll of course switch once shared_ptr becomes standard.

I doubt they will add much more if anything at all. If they really want this thing to be done before 2010, they are going to have to stop taking proposals real soon now. Lord only knows when compiler writers will start cranking on the new features.
[User Picture Icon]
From:xil
Date:April 11th, 2006 07:32 pm (UTC)
(Link)
Yea, that's true. Sucks though. I wish they had more resources and time to work on it. I mean, I definitely wouldn't want the C++ standard library to be like Java's library...bloated, and badly designed, but there's a lot of things that could be added to the library that would make life so much easier.

And yea, Loki's SmartPtr is well-designed, I kind of wish the standards body had adopted a pointer like his, with the customization aspect and all (I forget what Alexandrescu called it), and made the boost smart pointers defaults.




[User Picture Icon]
From:cbradfield
Date:April 11th, 2006 07:42 pm (UTC)
(Link)
Policy-based design
[User Picture Icon]
From:xil
Date:April 11th, 2006 02:25 pm (UTC)
(Link)
Oh yea, and something that annoys me greatly about Stroustrup's example:
where Usable_as<typename C::value_type,Shape*>

Then he says you could use, for example, a list<shared_ptr<shape>>. The thing is, a shared_ptr<Shape> *isn't* strictly usable as a Shape*, because you cannot assign to it, you cannot copy pointers from it (without calling get() at least). "Usable_as" is an almost useless concept if you take it's literal meaning. If they want it to only be usable_as in certain situations, they should pick another name for it.

Well, I guess you could say Usable_as<Shape const *> but I don't think shared_ptr's are convertible even to const pointers.
From:legolas
Date:April 17th, 2006 08:58 pm (UTC)
(Link)
What is in the article you referenced looks nice, in that it would make it easier for others/stl designers to make libraries that are easier to use and make my code look less like "scheme with < replacing (" !

What I think is really sad is that they know what 70% or so of the users need (a gui library) but just say "we don't have the time". I understand that they don't, and that it would be a giant undertaking to get it right, but still, how sad is that? There is a known, overwhelming need that isn't answered just because the C++ standard isn't owned by a vendor, like, say, Java or C#. It isn't even worked on in fact.

So everyone continues to make their own, or use a free one that doesn't work on half the platforms and doesn't even compile on the others, or a commercial one that supports only 'popular' platforms. And all other languages have it build in.

:-(
[User Picture Icon]
From:nponeccop
Date:July 7th, 2006 01:23 am (UTC)
(Link)
The C++ commitees are not "they". Anyone can contribute. Do you have time to develop a GUI library worth standardization? Just join a free GUI library project and make it compiling and working everywhere ;)
[User Picture Icon]
From:rraut1
Date:April 24th, 2006 02:07 am (UTC)
(Link)
I disagree that the standards committee should consider adding a gui library. User interfaces are still evolving. Gui class libraries are not a level where it make sense to standardize the current usage.

Java has a standard gui library, come to think of it, they have three. C# supports .Net, Windows Forms and Avalon (or whatever Microsoft is naming it at the moment). The standards committee is not in the business of imposing solutions.

I think concepts are a necessity that is overdue in the standard but what I would like to see it support for meta-functions. There are work-arounds but they make the code less readable.

A classic example is template int sizeof;
The sizeof() psuedofunction is a hack. You can't pass it as a template parameter. A metafunction would be suitable as a template parameter.
(Leave a comment)
Top of Page Powered by LiveJournal.com