Syntax [crayon-5c6ab5e6e6bee004567750/] 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-5c6ab5e6e6bfa153419745/] Given the following functions, how […]

General features: nullptr

Definition – unordered set / multiset [crayon-5c6ab5e6e7219005768377/] Definition – unordered map / multimap [crayon-5c6ab5e6e7223325117422/] Syntax [crayon-5c6ab5e6e7229686462374/] 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

Syntax [crayon-5c6ab5e6e76cb786806794/] 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

Syntax [crayon-5c6ab5e6e7cfc367683103/] 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

(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

Syntax [crayon-5c6ab5e6e84ca611131187/] 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