C++11







code
Syntax [crayon-5dab1262a17b2414163663/] Usage / Usability This feature is introduced mainly to take care of the pitfalls generated by using the (infamous and nasty) NULL macro. NULL is nothing but a preprocessor expanding to 0 at compile time and this expansion often leads to ambiguity. [crayon-5dab1262a17b9140586532/] Given the following functions, how […]

General features: nullptr


code
Definition – unordered set / multiset [crayon-5dab1262a1d9a338410881/] Definition – unordered map / multimap [crayon-5dab1262a1da3362200358/] Syntax [crayon-5dab1262a1da7710325158/] Internally, the elements are not sorted in any particular order, but organized into buckets. Which bucket an element is placed into depends entirely on the hash of its value. This allows fast access to […]

STL Containers: Unordered containers



code
Syntax [crayon-5dab1262a21c3435596150/] Usage / Usability Resolve the problems we had with the old enums Can be silently converted to int The enum ids are exported in the scope in which the enum is defined, causing name clashes They have implementation-defined underlying type – type cannot be specified by the developer […]

Miscellaneous: Strongly typed enums


code
Syntax [crayon-5dab1262a275e331183430/] decltype evalues the return type of a function or the type of a variable and uses it further. Trailing return types This is completely a new feature for C++ developers. Till now the return value of a function should go before the function’s name. From C++11, we can […]

Meta programming: decltype


sharing
(If you don’t know what are smart pointers, read the following post first!) One can create a shared_ptr object either via its constructors or through make_shared call from std. But what are the differences? Which one we should use? Let’s first talk about shared_ptr. What is shared_ptr? Shared ptr is […]

make_shared vs shared_ptr constructor



code
Syntax [crayon-5dab1262a2f64764324994/] Usage / Usability An object of type std::initializer_list<T> is a lightweight proxy object that provides access to an array of objects of type const T. Initializer lists allow the construction of any type using a curly-brace enclosed, comma-separated list of elements {a, b, c} Especially useful for providing […]

General features: Initializer list