Archives de la catégorie Trucs & Astuces

Moving an object that wraps a vector and an iterator on that vector

I recently stumbled upon code that looked very suspicious to me. Basically, it was a class which amongst other things held a vector and some iterators from that vector. Something like this: struct Wrapper {     typedef std::vector<int> Data;     Data data;     Data::iterator active;     Wrapper() :         data(),         active(data.end())     { } […]

, ,

Pas de commentaire

C++ Thread synchronization pitfall: using a barrier to synchronize a thread start

The context: You want to create a worker thread. Before the main thread goes on, you want to ensure that the worker thread starts. Using a boost::barrier seems like a good idea.

,

Pas de commentaire

Installing Google Play enabled firmware on Arnova 7b G3

Some time ago, our daughter bought an Arnova 7b G3 tablet. Although the device is very well done, its primary disadvantage is that it does not include Google Play. As a consequence, it is only possible to install new applications from the rather limited AppsLib. What she wanted was to be able to install applications […]

, , , , ,

Pas de commentaire

std::unique_ptr, virtual and missing virtual destructor = major pitfall

In our company, the build infrastructure runs unit tests in a valgrind shell, trying to detect memory leaks at the time the unit tests are executed. And every now and then, although our memory allocations are mostly handled through std::unique_ptr or std::shared_ptr, a leak pops up on the radar. And usually with the most useless […]

, ,

Pas de commentaire

Installing Skype 4 on a 64b Linux

It’s so easy they say on the website… Download the .deb and install. But problem: the .deb won’t install since it is meant for i386, not for x64.

, ,

Pas de commentaire

Installing GCC 4.7 in Ubuntu 12.04

Ubuntu 12.04 provides only GCC 4.6. To get GCC 4.7 (and its more advanced C++11 support), you need either to use Ubuntu 12.10 or you need to add a toolchain test repository. This page summarizes the latter option. To install GCC 4.7 in Ubuntu 12.04, do the following: sudo -s add-apt-repository ppa:ubuntu-toolchain-r/test apt-get update apt-get […]

, , ,

Pas de commentaire

Restaurer l’accès 3G/MMS de l’iPhone après un upgrade majeur

A chaque upgrade majeur de l’iPhone, c’est la même rangaine: le symbole 3G s’affiche mais pas de connexion et les MMS ne sont plus reçus, les paramètres se perdent dans la manoeuvre. Voici le résumé de ce qu’il faut faire pour récupérer les accès. Accès Internet par la 3G Dans Réglages, sélectionner Général > Réseau […]

, , , , ,

Pas de commentaire

Finding dangling symbolic links

The following command finds only broken symbolic links: $ find -L -type l This works because « -L » causes find to dereference symbolic links, in which case only broken links will have type « l ». This is probably unique to gnu find (from findutils). Based on comment in linuxforums.org.

Pas de commentaire

TotalFinder – juste ce qu’il manquait au Finder pour être complet…

Le Finder est le programme qui permet aux utilisateurs de Mac de gérer leurs fichiers. Il permet un certain nombre d’opérations mais comme c’est souvent le cas pour les applications built-in du Mac, il a un goût de « déjà vu en mieux ailleurs » (sous Linux, par exemple). Ainsi, il n’offre pas de mode « côte à […]

Pas de commentaire

Why does std::for_each return the Functor ?

In short: Because the provided Functor is copied by for_each. A bit longer: the functor has to be copied so that for_each can use a reference to it in the loopage as the functor is copied, the context of the functor would be lost at end of for_each if it was not returned class Object […]

,

Un commentaire