C++11

Start Using C++11 Now

Every major platform and compiler now supports some aspect of the new C++ standard accepted in 2011. This means it is currently possible to write code that uses some of C++11 while maintaining cross-platform compatibility.

Why should you care?

  1. By enabling C++11 compatibility with your compiler you are future proofing your code. You will be able to catch any portability errors sooner and be ready for the full move.

C++11: Decltype

decltype is a type specifier introduced in C++11. It behaves like a function that evaluates to the type of an object at compile time. This article is helping provide some more background information necessary for the more meatier C++11 articles to come.

decltype(4.23 * 5) v = 4.23*5;

In this example, the compiler is determining for us what the type of 4.23 * 5 would be and then giving that type to v.

With some help from typeid we can see that the type assigned by the compiler is double.

 

Syndicate content