Skip to content

Commit 0fde1ef

Browse files
authored
Merge pull request #10215 from Icinga/Al2Klimov-patch-3
Atomic<T>#Atomic(T): fix C++ compliance
2 parents d894792 + fb64c4f commit 0fde1ef

File tree

1 file changed

+8
-15
lines changed

1 file changed

+8
-15
lines changed

lib/base/atomic.hpp

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,32 +12,25 @@ namespace icinga
1212
{
1313

1414
/**
15-
* Extends std::atomic with an atomic constructor.
15+
* Like std::atomic, but enforces usage of its only safe constructor.
16+
*
17+
* "The default-initialized std::atomic<T> does not contain a T object,
18+
* and its only valid uses are destruction and
19+
* initialization by std::atomic_init, see LWG issue 2334."
20+
* -- https://en.cppreference.com/w/cpp/atomic/atomic/atomic
1621
*
1722
* @ingroup base
1823
*/
1924
template<class T>
2025
class Atomic : public std::atomic<T> {
2126
public:
2227
/**
23-
* Like std::atomic#atomic, but operates atomically
24-
*
25-
* @param desired Initial value
26-
*/
27-
inline Atomic(T desired)
28-
{
29-
this->store(desired);
30-
}
31-
32-
/**
33-
* Like std::atomic#atomic, but operates atomically
28+
* The only safe constructor of std::atomic#atomic
3429
*
3530
* @param desired Initial value
36-
* @param order Initial store operation's memory order
3731
*/
38-
inline Atomic(T desired, std::memory_order order)
32+
inline Atomic(T desired) : std::atomic<T>(desired)
3933
{
40-
this->store(desired, order);
4134
}
4235
};
4336

0 commit comments

Comments
 (0)