Monthly Archives: June 2018

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

C++ Techniques / Idioms 1. Resource acquisition is initialization (RAII) Definition Binds the life cycle of a resource that must be acquired before use (allocated heap memory, thread of execution, open socket, open file, locked mutex, disk space, database connection—anything that exists in limited supply) to the lifetime of an […]

C++ Techniques / Idioms

Syntax [crayon-5daeffb88960c929168374/]   New attributes: expects, ensures, assert – contract tools The following attributes specifies preconditions, postconditions, and assertions for functions. All of the predicates must be convertible to bool for interrogation purposes. They are both documentation and runtime asserts of how the caller should be expected to call the functions and in […]

Language features: Contracts

(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-5daeffb889da1112432172/] 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