mardi 29 novembre 2016

pre-increment vs post-increment on std::atomic

The common rule of thumb is to prefer using pre-increment on STL iterators in cases where the value is not immediately evaluated (i.e. you just want to increment the object/iterator). This is because in general the implementation of pre-increment is more efficient than post increment.

But what about std::atomic? If I run static analysis (using PVS studio) I get a warning saying that pre-increment should be more efficient, but when I look at the implementation of pre-increment (on Visual Studio 2015) it looks less efficient than post-increment?

Is there a general rule for using pre-increment over post-increment on STL atomic values or would it be implementation specific?

Aucun commentaire:

Enregistrer un commentaire