[constexpr] hb_atomic_int_t
diff --git a/src/hb-atomic.hh b/src/hb-atomic.hh
index 0abe50c..6048efe 100644
--- a/src/hb-atomic.hh
+++ b/src/hb-atomic.hh
@@ -221,9 +221,11 @@
#endif
-#define HB_ATOMIC_INT_INIT(V) {V}
struct hb_atomic_int_t
{
+ hb_atomic_int_t () = default;
+ constexpr hb_atomic_int_t (int v) : v (v) {}
+
void set_relaxed (int v_) { hb_atomic_int_impl_set_relaxed (&v, v_); }
void set (int v_) { hb_atomic_int_impl_set (&v, v_); }
int get_relaxed () const { return hb_atomic_int_impl_get_relaxed (&v); }
@@ -231,16 +233,17 @@
int inc () { return hb_atomic_int_impl_add (&v, 1); }
int dec () { return hb_atomic_int_impl_add (&v, -1); }
- int v;
+ int v = 0;
};
-
-#define HB_ATOMIC_PTR_INIT(V) {V}
template <typename P>
struct hb_atomic_ptr_t
{
typedef hb_remove_pointer<P> T;
+ hb_atomic_ptr_t () = default;
+ constexpr hb_atomic_ptr_t (T* v) : v (v) {}
+
void init (T* v_ = nullptr) { set_relaxed (v_); }
void set_relaxed (T* v_) { hb_atomic_ptr_impl_set_relaxed (&v, v_); }
T *get_relaxed () const { return (T *) hb_atomic_ptr_impl_get_relaxed (&v); }
@@ -250,7 +253,7 @@
T * operator -> () const { return get (); }
template <typename C> operator C * () const { return get (); }
- T *v;
+ T *v = nullptr;
};