DCSIMG
C++ 11 - class Alon : public CPP, public Architecture

class Alon : public CPP, public Architecture

The smart virtual home of Alon Fliess

Syndication

Browse by Tags

All Tags » C++ 11 (RSS)
Introduction to C++ 11 Series – Part 10, Ranged-Based for-Loops
Yes, this is post #10 in the C++ 11 series. The last post was long and complicated. In this post, I would like to write about something simpler - Ranged base loops. Ranged Based Loops, are like the C# foreach loop. The idea is to simplify iteration syntax on containers that have a begin ning, an end ing, and a forward iterator . Suppose we have this vector: vector < int > v ; for ( int i = 1 ; i <= 10 ; ++ i )        v . push_back ( i );   To iterate through...

Posted by Alon Fliess | with no comments

Introduction to C++ 11 Series – Part 9, R-Value, L-Value, Move Semantics and Perfect Forwarding
Take a deep breath; this is a long post about one of the most important and most complex features of C++ 11. One of the most performance-boost features of C++ 11 is the new move semantics addition to the language. This feature is based on a new reference – an R-Value reference. In this post, I am going to explain what R-Value (and L-Value) is, why we need it, and how we can use it to enable move constructor & move assignment operator. We will also see the std::move function and talk about perfect...

Posted by Alon Fliess | 2 comment(s)

Introduction to C++ 11 Series – Part 8, Lambda Expression or Functions
One of the most important features of C++ 11 is the addition of Lambda, an inline function mechanism (and a closure). Motivation The first motivation is to make this a valid C++ code: [](){}(); There are many reasons to use lambda and functional programing; for example, STL algorithms use function or functor objects. STL < functional > provides a set of functors such as plus , minus , less , equal_to , etc. Most of these functors are binary functions, i.e. they take two parameters. To use a...

Posted by Alon Fliess | with no comments

Introduction to C++ 11 Series – Part 7, decltype, auto (again) and Trailing Return Types
There is a joke, were a guy asks his friend, “Do you know what this is?” Doing some sort of wave shape movement with his hand. When his friend answers, “I don’t know”, the guy replies, “I don’t know either, but here comes another one like this!” decltype is, like the joke says, “another one like this”. It provides a way to use the type of an expression in any place that a type can be used: Declare a variable where the type of a given expression defines its type. Declare a function where its return...

Posted by Alon Fliess | 1 comment(s)

Introduction to C++ 11 Series – Part 6, auto – an old keyword with new meaning
Originally, auto declares a variable in the automatic storage, which is also the default behavior. This is still the behavior of the C language. In C++ 11, auto declares a variable, whose type is deduced from the initialization expression. If you are familiar with the C# var keyword, auto is almost the same. The main difference is that modifiers such as const, &, *, **, &&, static , and volatile can be added to the auto to enhance type declaration. auto is a productivity feature, it lets...

Posted by Alon Fliess | 1 comment(s)

Introduction to C++ 11 Series – Part 5, Copying & Re-throwing exceptions
Many of the new features of C++ 11 came from a real need, not just to make the language more productive but also to enable real-life scenarios. The ability to catch exception in one place in runtime environment and to re-throw it later came from the need to provide a better concurrency support in the language and libraries. C++ 11 has many new concurrent abilities that I will talk about in future posts, but now let us just say that we have, in standard C++, the ability to create and use threads....

Posted by Alon Fliess | 3 comment(s)

Introduction to C++ 11 Series – Part 4, Strongly Typed and Scoped enums
If you are familiar with C#/.NET enums, you know how safer and easier it is to have scoped enums. Like C#, the new C++ enums are scoped, and you can choose the underlined integral type for the enum.   Old C++ enum:   enum old_enum {        old_value };   The new syntax: (similar to the C# syntax)   enum newer_enum : unsigned long long {        newer_value = ~( unsigned long long ) 0 };   The new enum provides: enumerators...

Posted by Alon Fliess | 6 comment(s)

Introduction to C++ 11 Series – Part 3, Local & Unnamed Types as Template Arguments
In this post, I am going to write about a new feature, that your response might be “Ha! I didn’t know I can do that”. The old C++ standard says that local types, unnamed types and in general, types with no linkage, shall not be used as template arguments. In C++ 11 this has been solved : local types have the same linkage as their enclosing function Unnamed types have the same linkage they would have if they were named To show the change look at this code:   template < class T > void typeid_of...

Posted by Alon Fliess | 2 comment(s)

Introduction to C++ 11 Series – Part 2, the nullptr
nullptr is a real NULL pointer. Look at this sample: void   nullptr_overload( int   i) { cout << "int"   << endl; } void   nullptr_overload( int   *p) { cout << "int *"   << endl; } void   main() {       nullptr_overload(0);       nullptr_overload(NULL);       nullptr_overload( nullptr ); } Can you guess the result? The new nullptr is not another...

Posted by Alon Fliess | 1 comment(s)

The C++ 11 Standard & Visual Studio – Introduction
  C++ 11, formerly known as C++0x, was published as ISO/IEC 14882:2011 in September 2011. The standard document is available for a fee, however the most recent draft, before the release, was N3242 and the most recent working draft freely available is N3337 , dated 26 January 2012. C++11 includes several additions to the core language and extends the C++ standard library incorporating most of C++ TR1 libraries and many other features, most of them originated from the boost library. C++ 11 is...

Posted by Alon Fliess | 1 comment(s)

Developing a Windows Store app using C++ and XAML
Like any Windows API , Windows Store Application s API is based on native code. Unlike the old Win32 API, the new native interface is not based on the C language prototype, nor the old COM programming model. Microsoft has realized that the .NET type system provides modern, richer and more productive alternative. To have .NET productivity in native code, Microsoft has borrowed the type system principles ( ECMA 335 CLI type system) and merged it with the COM programming model. In Windows Store API...

Posted by Alon Fliess | with no comments

Windows Platform User Group Next Meeting
I’ve had the chance to take part in the last BUILD conference. It is true that you don’t have to travel to the other side of the world to get the new knowledge. You can follow the tweets, read the blogs and watch the online videos. However being at the conference gives you the opportunity and time to be focused and the ability to meet people and build your perception about the future of the current and new technologies. And there is a lot to think about: The future of Windows, The future of .NET...

Posted by Alon Fliess | 1 comment(s)

My Build Event Insights
You didn't have to go to //BUILD/ to get the information and knowledge of the new Windows Platform APIs; you could watch all the sessions from the comfort of your home, and I encourage you to do so, however attending the conference helps obtaining a perception about the future of Microsoft and especially the future of Windows technologies and the reaction of the developers that attended the conference. I didn't want to post about the conference before I have a clear picture, and believe me...

Posted by Alon Fliess | 14 comment(s)