Yearly Archives: 2017


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





code
Angle brackets Two consecutive right angle brackets must be separated by whitespace: [crayon-5d0b40baaece2289229814/] Binary literals [crayon-5d0b40baaeceb212531604/] Deprecated  attributes [crayon-5d0b40baaecf0741075164/] 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





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


fw_list
Syntax Defined in header <forward_list> [crayon-5d0b40baafdb6356501634/] Definitions List definition [crayon-5d0b40baafdbe179450932/] Forward list definition [crayon-5d0b40baafdc3037831007/] 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


code
Syntax [crayon-5d0b40bab0242711975972/] 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-5d0b40bab024b071815349/] bind returns a new function object with a different prototype because […]

Miscellaneous: Function / Bind



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