Skip to content

Commit 81a930f

Browse files
Adapt MemoryOrder definition for C++ 20 (#533)
When compiling the code with C++ 20 the following error message is produced: enumerator value for ‘MEMORY_ORDER_RELAXED’ must have integral or unscoped enumeration type This is because with C++ 20 the type of those values changed to an enum class. The `static_cast` extracts the numeric values so they can be used here as before.
1 parent b375049 commit 81a930f

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/atomic/atomic_std.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@
2222
namespace datastax { namespace internal {
2323

2424
enum MemoryOrder {
25-
MEMORY_ORDER_RELAXED = std::memory_order_relaxed,
26-
MEMORY_ORDER_CONSUME = std::memory_order_consume,
27-
MEMORY_ORDER_ACQUIRE = std::memory_order_acquire,
28-
MEMORY_ORDER_RELEASE = std::memory_order_release,
29-
MEMORY_ORDER_ACQ_REL = std::memory_order_acq_rel,
30-
MEMORY_ORDER_SEQ_CST = std::memory_order_seq_cst
25+
MEMORY_ORDER_RELAXED = static_cast<std::underlying_type<std::memory_order>::type>(std::memory_order_relaxed),
26+
MEMORY_ORDER_CONSUME = static_cast<std::underlying_type<std::memory_order>::type>(std::memory_order_consume),
27+
MEMORY_ORDER_ACQUIRE = static_cast<std::underlying_type<std::memory_order>::type>(std::memory_order_acquire),
28+
MEMORY_ORDER_RELEASE = static_cast<std::underlying_type<std::memory_order>::type>(std::memory_order_release),
29+
MEMORY_ORDER_ACQ_REL = static_cast<std::underlying_type<std::memory_order>::type>(std::memory_order_acq_rel),
30+
MEMORY_ORDER_SEQ_CST = static_cast<std::underlying_type<std::memory_order>::type>(std::memory_order_seq_cst)
3131
};
3232

3333
template <class T>

0 commit comments

Comments
 (0)