C++0x in Visual Studio 10

Posted on:October 29 2008

Visual Studio 10 has been released as beta version (named CTP for Community Technology Preview) and its compiler has some parts of C++0x implemented. The best feature: The auto keyword. I really love it. No more typing the foo<bar::baz>::iterator part in
foo<bar::baz>::iterator xy = something.begin();
The Visual C++ Team blog also has a very nice post explaining the new features, especially lamdas in detail. A feature which I still don't like very much, it is quite sensless IMO because it only adds complexity to the language without adding a real new feature, you can emulate lamdas anyway using templates. Or is it obvious what this code does?

for_each(v.begin(), v.end(), [=](int& r) mutable {      const int old = r;      r *= x * y;      //etc  });

But anyway, nice.





Comments:


Thanks, *downloading*
doc
Quote
2008-10-29 19:05:00


ad lambdas: actually without them the whole algorithms header really doesn't make sense. the boost lambdas are a workaround, nothing more (there are tons of expressions you cannot reasonably write using them).

I do not think foreach is the most reasonable example, copy_if etc. might make more sense. lambdas may even allow the suggested functional style (suggested by the STL design) to work, using a few templates for representing lazily filtered collections, for example. the syntax is not particularily nice, ok, but not too unreasonable.

the feature I like best (don't know if its in the CTP) is 'concepts'. I think non-concept-based templates (whilst being necessary for learning) never were a good idea, and concepts enable much better compiler diagnostics and much improved contract checking.

regarding useless complexity in the language: c++fqa, anybody?
xaos
Quote
2008-10-29 19:23:00


Do they provide a "strict" C++ mode in Visual Studio 10 ?
Hervé
Quote
2008-10-29 23:02:00


Did they ever?
zutuk
Quote
2008-10-30 10:13:00


Lambdas are definintely useful in their place, to stop you having to define structs just to provide a custom operator for a std::sort call or similar.
steve
Quote
2008-10-30 10:18:00


Shame, the link doesn't work anymore
Parsa
Quote
2008-10-30 21:19:00


yep, they removed it because the image contained some private debugging symbols of the windows source code :)
niko
Quote
2008-10-31 15:23:00


Ah! A fix! http://blogs.msdn.com/othmane/archive/2008/10/30/visual-studio-2010-net-framework-4-0-ctp-download-temporarily-unavailable.aspx
Parsa
Quote
2008-11-01 13:05:00


Useful example of lambda usage: http://cschleiden.spaces.live.com/blog/cns!A8BBB8A086E51796!170.entry
CSchleiden
Quote
2008-11-02 01:46:00


Add comment:


Posted by:


Enter the missing letter in: "?nternational"


Text:

 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons