Yearly Archives: 2017

Syntax [crayon-5d5b954142dc8248598644/]   [crayon-5d5b954142dd3855301904/] 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-5d5b954144475263534287/] Binary literals [crayon-5d5b95414447e102516676/] Deprecated  attributes [crayon-5d5b954144483689954256/] 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-5d5b954145151887447346/] 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-5d5b954145619703247068/] Definitions List definition [crayon-5d5b954145622456403497/] Forward list definition [crayon-5d5b954145626923556561/] 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-5d5b954145a8c862856638/] 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-5d5b954145a95748782910/] bind returns a new function object with a different prototype because […]

Miscellaneous: Function / Bind

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