Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion stl/inc/atomic
Original file line number Diff line number Diff line change
Expand Up @@ -1365,7 +1365,7 @@ struct _Atomic_integral<_Ty, 1> : _Atomic_storage<_Ty> { // atomic integral oper
}

_TVal operator--(int) noexcept {
return static_cast<_Ty>(_InterlockedExchangeAdd8(_Atomic_address_as<char>(this->_Storage), -1));
return static_cast<_TVal>(_InterlockedExchangeAdd8(_Atomic_address_as<char>(this->_Storage), -1));
}

_TVal operator--() noexcept {
Expand Down Expand Up @@ -1810,6 +1810,22 @@ struct _Atomic_integral_facade<_Ty&> : _Atomic_integral<_Ty&> {
return fetch_add(_Negate(_Operand), _Order);
}

_Ty operator++(int) const noexcept {
return const_cast<_Atomic_integral_facade*>(this)->_Base::operator++(0);
}

_Ty operator++() const noexcept {
return const_cast<_Atomic_integral_facade*>(this)->_Base::operator++();
}

_Ty operator--(int) const noexcept {
return const_cast<_Atomic_integral_facade*>(this)->_Base::operator--(0);
}

_Ty operator--() const noexcept {
return const_cast<_Atomic_integral_facade*>(this)->_Base::operator--();
}

_Ty operator+=(const _Ty _Operand) const noexcept {
return static_cast<_Ty>(fetch_add(_Operand) + _Operand);
}
Expand Down
8 changes: 8 additions & 0 deletions tests/std/tests/P0019R8_atomic_ref/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,14 @@ void test_int_ops() {
assert(vy.load() == 0x40);
assert(rx.load() == 0x33);
assert(ry.load() == 0x33);

vx--;
rx--;

assert(vx.load() == 0x32);
assert(vy.load() == 0x40);
assert(rx.load() == 0x32);
assert(ry.load() == 0x32);
}


Expand Down