File tree Expand file tree Collapse file tree 1 file changed +8
-7
lines changed
src/hotspot/share/runtime Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -512,17 +512,18 @@ class AtomicImpl::Atomic<T, AtomicImpl::Category::Translated>
512512 static Decayed decay (T x) { return Translator::decay (x); }
513513 static T recover (Decayed x) { return Translator::recover (x); }
514514
515+ // Support for default construction via the default construction of _value.
516+ struct UseDecayedCtor {};
517+ explicit Atomic (UseDecayedCtor) : _value() {}
518+ using DefaultCtorSelect =
519+ std::conditional_t <std::is_default_constructible_v<T>, T, UseDecayedCtor>;
520+
515521public:
516522 using ValueType = T;
517523
518524 // If T is default constructible, construct from a default constructed T.
519- template <typename Dep = T, ENABLE_IF(std::is_default_constructible_v<Dep>)>
520- Atomic () : Atomic(T()) {}
521-
522- // If T is not default constructible, default construct the underlying
523- // Atomic<Decayed>.
524- template <typename Dep = T, ENABLE_IF(!std::is_default_constructible_v<Dep>)>
525- Atomic () : _value() {}
525+ // Otherwise, default construct the underlying Atomic<Decayed>.
526+ Atomic () : Atomic(DefaultCtorSelect()) {}
526527
527528 explicit Atomic (T value) : _value(decay(value)) {}
528529
You can’t perform that action at this time.
0 commit comments