Constant evaluable in the standard library

Just a quick question, I've been reading the source code of the standard library, specifically the atomics, and I saw a lot of these which I don't understand:

@_semantics("constant_evaluable")

I'm curious, what does it do? Is it like constexpr? :slightly_smiling_face:

1 Like

I've been wondering also, I think it is like constexpr but only for OSLog and Atomics. Notice we can't do this:

import Synchronization
let ordering = AtomicUpdateOrdering.relaxed
let a = Atomic(0)
a.add(1, ordering: ordering) // error: Ordering argument must be a static
                             // method or property of 'AtomicUpdateOrdering'

Also take a look at isParamRequiredToBeConstant.

2 Likes