dimanche 21 janvier 2018

Why free functions exit for compare and swap operation?

C++ Standard Library has both free functions and member functions for atomic compare and swap operation.

As noted for free functions:

These functions are defined in terms of member functions of std::atomic:
1) obj->compare_exchange_weak(*expected, desired)
2) obj->compare_exchange_strong(*expected, desired)
3) obj->compare_exchange_weak(*expected, desired, succ, fail)
4) obj->compare_exchange_strong(*expected, desired, succ, fail)

What is the reason that free functions exit? Wouldn't it be enough for member functions only? Doesn't they do the same thing?

Aucun commentaire:

Enregistrer un commentaire