Syntax [crayon-5dab10d62270e244162178/]   Tuples and data fetching Tuples are suggested for returning multiple values from a function. They are in a strong relation with std::tie, which is used for retrieving the values. The only problem is that we have to have all those variables previously declared. [crayon-5dab10d62271b476888305/] But what if […]

Language feature: Structured binding

Syntax [crayon-5dab10d623a57397690949/] std::quoted was added in C++14 and it is used to take care of escaping quotes and backslashes in output streams, and unescaping them in input streams. This is handy for example if we want to use it in an SQL statement, in both ways (either add the escaping, […]

std::quoted and the “friendly” delimiters

String conversions using stringstream Stringstream can be used to get values from a string, by using stringstream as adaptor. Stringstream also has the operator << for adding a string into its stream. In case the conversion fails (trying to add “abc” into an int for example), the value of the […]

Conversions using std::to_string and “from_string”

lightning talk
Lambda under the hood What if we capture by reference instead? [&] vs [=] Lambda template Move cannot move if const C++17: Clamp Before C++17, we were relying on the following code (or similar) to clamp a value. Now, with C++17, we can simply use std::clamp. Reverse Unique Sort Algos […]

Lightning talk #7 – C++ functionality: Did you know… ...

lightning talk
Paranthesis [crayon-5dab10d62597d723034257/] Returning non-bools [crayon-5dab10d62598a110420252/] Returning bools [crayon-5dab10d625991154157497/] Reusing data Similar behavior in if/else branches [crayon-5dab10d625998896662062/] Similar behavior in if/else branches [crayon-5dab10d62599f703704306/] Same behavior on both branches – move it outside the branches. [crayon-5dab10d6259a6901872198/] Condition that appears on all steps – Check it only once. [crayon-5dab10d6259ac185262763/]

Lightning talk #6 – Refactoring steps

Definition [crayon-5dab10d6261eb219967873/] Fills the range [first, last) with sequentially increasing values, starting with value and repetitively evaluating ++value.   Syntax [crayon-5dab10d626213539213877/] But now let’s create a custom incrementable class. Iota is working with a T type, so we only need to overload the ++ operator. [crayon-5dab10d62622a150383299/] So what do we have here? I’ve added a […]

std::iota and custom incrementable

trip report
A few days ago there was the WG21 meeting in San Diego and the committee have some excellent news for the upcoming C++20 and C++23. From the major features: Ranges, Concepts, and Contracts were merged into the C++20 standard. Modules and Coroutines will most likely be added in C++23. For […]

(C++20) 2018 San Diego ISO C++ Committee Trip Report : ...

Below you’ll find a list of problems I’ve made for testing the modern C++ knowledge. There are no hints here, so this is a knowledge check. Refactor as much as you want. All the answers are in my other posts, feel free to check them here. [crayon-5dab10d62692b957306258/]  

Practical work: Refactoring old code to Modern C++ (11 / ...

Definition std::terminate is called when exception handling fails, if: an exception was thrown and not handled the constructor or the destructor of a static or thread-local object throws an exception a noexcept specification is violated (exception is thrown in a function declared noexcept) …and many others – But these are […]

using std::terminate or “how to call that last function before ...

Hello guys, CPPCon 2018 is here (on youtube actually) so there’s a whole bunch of new videos ready to be seen. Click here for the playlist! Enjoy your view!

CPPCon 2018 is here!

Syntax [crayon-5dab10d627293502433710/] Usage / Usability This feature is introduced mainly to take care of the pitfalls generated by using the (infamous and nasty) NULL macro. NULL is nothing but a preprocessor expanding to 0 at compile time and this expansion often leads to ambiguity. [crayon-5dab10d62729c825709614/] Given the following functions, how […]

General features: nullptr