``atomic_compare_exchange_strong`` ================================== .. warning:: Deprecated since Kokkos 4.5, use `atomic_compare_exchange `_ instead. .. role:: cpp(code) :language: cpp Defined in header ```` which is included from ```` Usage ----- .. code-block:: cpp bool was_exchanged = atomic_compare_exchange_strong(&obj, expected, desired); // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ // deprecated since Kokkos 4.5 // instead prefer // expected == atomic_compare_exchange(&obj, expected, desired) Atomically compares the current value of ``obj`` with ``expected`` and replaces its value with ``desired`` if equal. The function returns ``true`` if the exchange has happened, ``false`` otherwise. Description ----------- .. cpp:function:: template bool atomic_compare_exchange_strong(T* ptr, std::type_identity_t expected, std::type_identity_t desired); Atomically compares ``*ptr`` with ``expected``, and if those are bitwise-equal, replaces the former with ``desired``. If ``desired`` is written into ``*ptr`` then ``true`` is returned. ``if (*ptr == expected) { *ptr = desired; return true; } else return false;`` :param ptr: address of the object to test and to modify :param expected: value expected to be found in the object :param desired: the value to store in the object if as expected :returns: the result of the comparison, ``true`` if ``*ptr`` was equal to ``expected``, ``false`` otherwise