Yearly Archives: 2017

Syntax [crayon-5c6ab3b462009434259101/]   [crayon-5c6ab3b462019560593315/] Variadic templates essentially allow recursion to be replaced by iteration Variadic templates needs an end function – usually it’s a specialization for the last remaining parameter, in order to stop the recursion. This has changed in C++17 and is no longer needed.

Meta programming: Variadic templates

Angle brackets Two consecutive right angle brackets must be separated by whitespace: [crayon-5c6ab3b463cc1603250590/] Binary literals [crayon-5c6ab3b463cca854174018/] Deprecated  attributes [crayon-5c6ab3b463cd0874868532/] Single quotation mark as separator The literals 1.602’176’565 and 1.602176565 have the same value. Unrestricted unions In Standard C++ there are restrictions on what types of objects can be members of […]

Miscellaneous: Small changes

Syntax [crayon-5c6ab3b46496e741854453/] Provide default values Useful for providing default values for its members. This also reduce the number of members that needs to be initialized per constructor. In case the member contains a default initialization and is also set on constructor, the constructor will override the value.   Pitfalls Initialization […]

Classes: In-class member initializers

Syntax Defined in header <forward_list> [crayon-5c6ab3b464e64620648913/] Definitions List definition [crayon-5c6ab3b464e6d543077447/] Forward list definition [crayon-5c6ab3b464e73106438628/] The main difference between a list and a forward list is the pointer to the previous node.   About forward list is a container that supports fast insertion and removal of elements from anywhere in the […]

STL Containers: Forward list

Syntax [crayon-5c6ab3b465327054666134/] std::function is a wrapper to a simple function, to a functor or to a lambda expression. std::bind is a template function that returns a std::function object that binds a set of arguments to a function.   [crayon-5c6ab3b465330945794140/] bind returns a new function object with a different prototype because […]

Miscellaneous: Function / Bind

Syntax [crayon-5c6ab3b465864770065299/]   [crayon-5c6ab3b46586d601143007/] Functionality It is used to inhibit unintended implicit conversions to bool. Such conversion functions are called explicit conversion operators. In the code below, we have the operator bool, but it’s not marked as explicit. When we want to do + and == calls on objects of […]

Classes: Explicit conversion operators