Monthly Archives: June 2018


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


brainstorming
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


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



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-5c6ab4476e0f4264204517/] 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