Introduction to C++ 11 Series – Part 7, decltype, auto (again) and Trailing Return Types

March 28, 2013

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...

Introduction to C++ 11 Series – Part 6, auto – an old keyword with new meaning

March 27, 2013

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 you write code faster. auto is also an abstraction enhancer; you...

Introduction to C++ 11 Series – Part 5, Copying & Re-throwing exceptions

March 25, 2013

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. In order to understand why we need...

Introduction to C++ 11 Series – Part 4, Strongly Typed and Scoped enums

March 24, 2013

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: ...

Introduction to C++ 11 Series – Part 3, Local & Unnamed Types as Template Arguments

March 23, 2013

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: ...

Introduction to C++ 11 Series – Part 2, the nullptr

March 22, 2013

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 representation of 0 (zero) but it is an instance of a new type. Here are some facts: • nullptr is a reserved keyword for a constant (rvalue) of type std::nullptr_t ...

The C++ 11 Standard & Visual Studio – Introduction

March 21, 2013

  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 a new language and as such, you need to learn what is in there for you...

Kinect for Windows SDK Programming Guide by Abhijit Jana book review

March 13, 2013

Since the release of Kinect for PC I had the opportunity to take part and be involved with several Kinect based projects. Starting developing with the Kinect SDK is something that most .NET and native C++ developers can handle very easily. Just download and install the SDK, hook a Kinect device (you can use the Xbox Kinect, however you will need a power cable and do remember that it is just for the development process and some features, like near mode, will not work), run the Kinect toolkit browser, see the sample, read the document and open the source...
4 comments