From 8a69e0063936764cbd149985e0b57e1dc35935c2 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Thu, 13 Jan 2022 16:17:34 -0700 Subject: [PATCH] [meta] Use std::addressof() instead of hb_addressof() --- src/hb-algs.hh | 2 +- src/hb-iter.hh | 2 +- src/hb-map.hh | 4 ++-- src/hb-meta.hh | 20 ++------------------ src/hb-ot-cmap-table.hh | 2 +- src/hb-ot-color-colrv1-closure.hh | 2 +- src/hb-ot-name-table.hh | 2 +- src/hb-serialize.hh | 10 +++++----- 8 files changed, 14 insertions(+), 30 deletions(-) diff --git a/src/hb-algs.hh b/src/hb-algs.hh index 3edca3344..df03b9729 100644 --- a/src/hb-algs.hh +++ b/src/hb-algs.hh @@ -880,7 +880,7 @@ hb_bsearch_impl (unsigned *pos, /* Out */ #pragma GCC diagnostic ignored "-Wcast-align" V* p = (V*) (((const char *) base) + (mid * stride)); #pragma GCC diagnostic pop - int c = compar ((const void *) hb_addressof (key), (const void *) p, ds...); + int c = compar ((const void *) std::addressof (key), (const void *) p, ds...); if (c < 0) max = mid - 1; else if (c > 0) diff --git a/src/hb-iter.hh b/src/hb-iter.hh index 34887fd57..43a3098f6 100644 --- a/src/hb-iter.hh +++ b/src/hb-iter.hh @@ -91,7 +91,7 @@ struct hb_iter_t * TODO Use a wrapper return type to fix for non-reference type. */ template ::value)> - hb_remove_reference* operator -> () const { return hb_addressof (**thiz()); } + hb_remove_reference* operator -> () const { return std::addressof (**thiz()); } item_t operator * () const { return thiz()->__item__ (); } item_t operator * () { return thiz()->__item__ (); } item_t operator [] (unsigned i) const { return thiz()->__item_at__ (i); } diff --git a/src/hb-map.hh b/src/hb-map.hh index bb5531b31..f091aa08c 100644 --- a/src/hb-map.hh +++ b/src/hb-map.hh @@ -69,9 +69,9 @@ struct hb_hashmap_t void clear () { - new (hb_addressof (key)) K (); + new (std::addressof (key)) K (); key = hb_coerce (kINVALID); - new (hb_addressof (value)) V (); + new (std::addressof (value)) V (); value = hb_coerce (vINVALID); hash = 0; } diff --git a/src/hb-meta.hh b/src/hb-meta.hh index 60bec551d..88b515339 100644 --- a/src/hb-meta.hh +++ b/src/hb-meta.hh @@ -85,22 +85,6 @@ template <> struct hb_priority<0> {}; template struct hb_type_identity_t { typedef T type; }; template using hb_type_identity = typename hb_type_identity_t::type; -struct -{ - template constexpr T* - operator () (T& arg) const - { -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wcast-align" - /* https://en.cppreference.com/w/cpp/memory/addressof */ - return reinterpret_cast ( - &const_cast ( - reinterpret_cast (arg))); -#pragma GCC diagnostic pop - } -} -HB_FUNCOBJ (hb_addressof); - template static inline T hb_declval (); #define hb_declval(T) (hb_declval ()) @@ -157,7 +141,7 @@ struct operator () (T&& v) const HB_AUTO_RETURN (std::forward (v)) template constexpr auto - operator () (T& v) const HB_AUTO_RETURN (hb_addressof (v)) + operator () (T& v) const HB_AUTO_RETURN (std::addressof (v)) } HB_FUNCOBJ (hb_ref); @@ -174,7 +158,7 @@ struct hb_reference_wrapper template struct hb_reference_wrapper { - hb_reference_wrapper (T& v) : v (hb_addressof (v)) {} + hb_reference_wrapper (T& v) : v (std::addressof (v)) {} bool operator == (const hb_reference_wrapper& o) const { return v == o.v; } bool operator != (const hb_reference_wrapper& o) const { return v != o.v; } operator T& () const { return *v; } diff --git a/src/hb-ot-cmap-table.hh b/src/hb-ot-cmap-table.hh index d837adc78..9b3607ac4 100644 --- a/src/hb-ot-cmap-table.hh +++ b/src/hb-ot-cmap-table.hh @@ -1607,7 +1607,7 @@ struct cmap unsigned format = (this + _.subtable).u.format; if (format == 12) has_format12 = true; - const EncodingRecord *table = hb_addressof (_); + const EncodingRecord *table = std::addressof (_); if (_.platformID == 0 && _.encodingID == 3) unicode_bmp = table; else if (_.platformID == 0 && _.encodingID == 4) unicode_ucs4 = table; else if (_.platformID == 3 && _.encodingID == 1) ms_bmp = table; diff --git a/src/hb-ot-color-colrv1-closure.hh b/src/hb-ot-color-colrv1-closure.hh index ca85ba6ad..fbaf2ec26 100644 --- a/src/hb-ot-color-colrv1-closure.hh +++ b/src/hb-ot-color-colrv1-closure.hh @@ -43,7 +43,7 @@ HB_INTERNAL void PaintColrLayers::closurev1 (hb_colrv1_closure_context_t* c) con const LayerList &paint_offset_lists = c->get_colr_table ()->get_layerList (); for (unsigned i = firstLayerIndex; i < firstLayerIndex + numLayers; i++) { - const Paint &paint = hb_addressof (paint_offset_lists) + paint_offset_lists[i]; + const Paint &paint = std::addressof (paint_offset_lists) + paint_offset_lists[i]; paint.dispatch (c); } } diff --git a/src/hb-ot-name-table.hh b/src/hb-ot-name-table.hh index c17bb4abb..792de061a 100644 --- a/src/hb-ot-name-table.hh +++ b/src/hb-ot-name-table.hh @@ -256,7 +256,7 @@ struct name }) ; - name_prime->serialize (c->serializer, it, hb_addressof (this + stringOffset)); + name_prime->serialize (c->serializer, it, std::addressof (this + stringOffset)); return_trace (name_prime->count); } diff --git a/src/hb-serialize.hh b/src/hb-serialize.hh index 823c0be8b..7fee413c5 100644 --- a/src/hb-serialize.hh +++ b/src/hb-serialize.hh @@ -510,7 +510,7 @@ struct hb_serialize_context_t { return reinterpret_cast (this->head); } template Type *start_embed (const Type &obj) const - { return start_embed (hb_addressof (obj)); } + { return start_embed (std::addressof (obj)); } bool err (hb_serialize_error_t err_type) { @@ -548,7 +548,7 @@ struct hb_serialize_context_t } template Type *embed (const Type &obj) - { return embed (hb_addressof (obj)); } + { return embed (std::addressof (obj)); } template auto _copy (const Type &src, hb_priority<1>, Ts&&... ds) HB_RETURN @@ -595,19 +595,19 @@ struct hb_serialize_context_t } template Type *extend_size (Type &obj, size_t size) - { return extend_size (hb_addressof (obj), size); } + { return extend_size (std::addressof (obj), size); } template Type *extend_min (Type *obj) { return extend_size (obj, obj->min_size); } template - Type *extend_min (Type &obj) { return extend_min (hb_addressof (obj)); } + Type *extend_min (Type &obj) { return extend_min (std::addressof (obj)); } template Type *extend (Type *obj, Ts&&... ds) { return extend_size (obj, obj->get_size (std::forward (ds)...)); } template Type *extend (Type &obj, Ts&&... ds) - { return extend (hb_addressof (obj), std::forward (ds)...); } + { return extend (std::addressof (obj), std::forward (ds)...); } /* Output routines. */ hb_bytes_t copy_bytes () const