Clamping values with style

The following question was raised in one of our software devs channel at work: On style and readability and intent : std::min or std::clamp or explicit if/reassign. Option 1: int x = someValue;if (x > max) { x = max;} Option 2: int x = std::min(someValue, max); Option 3: int x = std::clamp(someValue, 0, max); […]

Pas de commentaire

Proper handling of temporary objects

Purpose Making a wrapper that keeps reference to some constructor arguments.That’s OK as long as the wrapper lifetime is longer or equal to its construction arguments. If the wrapper is created from temporary objects, it should better be used in the same line _or_ it will make reference to possibly destroyed objects. Example Available on […]

Pas de commentaire

Cookie de l’école de Perbais

Ingrédients 250gr de farine fermentante (ou farine à patisserie + 1 cc de bicarbonate de soude + levure) 100gr de flocons d’avoine 100gr de pépites de chocolat 100gr de sucre blanc 100gr de cassonade 125gr de beurre (ramoli) 1 oeuf (battu) Préparation Mélanger tous les ingrédients dans un saladier. Disposer des petites boules de pâtes […]

,

Pas de commentaire

Vol au vent minute

Ingrédients 400gr de filets de poulet 200gr de haché 300gr de champignons 100ml de lait 50ml de crème fraîche 3 c.a.s de farine fermentante 1 citron épices pour poulet Préparation confectionner de petites boulettes avec le haché découper les filets de poulet en petits dés les déposer dans le plat pour micro-ondes ajouter les épices […]

, , ,

Pas de commentaire

The Hidden Dangers of std::function and lambdas

Once upon a time, there was an active object which had callbacks using std::function.On the same day, a user of this object registered a callback function which, in its core, cancelled the registration. That callback was a lambda that aside of that took some reference in the current context.And guess what happened ? Here is […]

Pas de commentaire

Making patch files

Assume you have a library X, version 1.2.3, extracted in libX-1.2.3/ and that you have to integrate some fix in the build process. You would create a patch file that is applied before building that library. But how do you make the patch files depend on how you apply them. To start, you save the […]

Pas de commentaire

Noix de Saint-Jacques au cidre

Ingrédients 500g de coquilles Saint-Jacques, nettoyées et prêtes à cuire 50g de beurre 2 échalotes hachées menu 40g de farine 150ml de cidre brut 50ml de lait 100g de champignons émincés sel et poivre moulu 250ml de crème fraîche épaisse persil haché pour la garniture Recette Dans le plat Ultra+, mettre le beurre et les échalotes. […]

, ,

Pas de commentaire

Panic moments: Ubuntu wouldn’t boot properly after upgrade to Xenial

Xenial being released for quite some time now, I decided on a sunny Friday afternoon to do the big jump from Trusty to the latest greatest release. Used to the command line, I launch the "do-release-upgrade" command. 1500+ MB of packets to be downloaded, thousands to be upgraded, some new to be installed and about […]

,

Pas de commentaire

Untabify from the Linux command line

Every now and then, we get some source file that has those nasty relics from a distant path, namely tabs instead of spaces to make indentation. Of course, you can load the affected files one by one in your favorite editor and provided that you can specify some kind of regular expression in a global […]

Pas de commentaire

boost goodie to clamp numbers

How do you clamp a number in a given range in C++ ? Classical way to do it is: double clamped = std::min(maxValue, std::max(minValue, value)) But why repeat this magic formula when boost has clamp() for you ? From now on, do: #include double clamped = boost::algorithm::clamp(value, minValue, maxValue)

,

Pas de commentaire