[meta] Use std::addressof() instead of hb_addressof()

This commit is contained in:
Behdad Esfahbod 2022-01-13 16:17:34 -07:00
parent b7b0a15f7e
commit 8a69e00639
8 changed files with 14 additions and 30 deletions

View File

@ -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)

View File

@ -91,7 +91,7 @@ struct hb_iter_t
* TODO Use a wrapper return type to fix for non-reference type. */
template <typename T = item_t,
hb_enable_if (std::is_reference<T>::value)>
hb_remove_reference<item_t>* operator -> () const { return hb_addressof (**thiz()); }
hb_remove_reference<item_t>* 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); }

View File

@ -69,9 +69,9 @@ struct hb_hashmap_t
void clear ()
{
new (hb_addressof (key)) K ();
new (std::addressof (key)) K ();
key = hb_coerce<K> (kINVALID);
new (hb_addressof (value)) V ();
new (std::addressof (value)) V ();
value = hb_coerce<V> (vINVALID);
hash = 0;
}

View File

@ -85,22 +85,6 @@ template <> struct hb_priority<0> {};
template <typename T> struct hb_type_identity_t { typedef T type; };
template <typename T> using hb_type_identity = typename hb_type_identity_t<T>::type;
struct
{
template <typename T> 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<T*> (
&const_cast<char&> (
reinterpret_cast<const volatile char&> (arg)));
#pragma GCC diagnostic pop
}
}
HB_FUNCOBJ (hb_addressof);
template <typename T> static inline T hb_declval ();
#define hb_declval(T) (hb_declval<T> ())
@ -157,7 +141,7 @@ struct
operator () (T&& v) const HB_AUTO_RETURN (std::forward<T> (v))
template <typename T> 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 <typename T>
struct hb_reference_wrapper<T&>
{
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; }

View File

@ -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;

View File

@ -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);
}
}

View File

@ -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);
}

View File

@ -510,7 +510,7 @@ struct hb_serialize_context_t
{ return reinterpret_cast<Type *> (this->head); }
template <typename Type>
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 <typename Type>
Type *embed (const Type &obj)
{ return embed (hb_addressof (obj)); }
{ return embed (std::addressof (obj)); }
template <typename Type, typename ...Ts> auto
_copy (const Type &src, hb_priority<1>, Ts&&... ds) HB_RETURN
@ -595,19 +595,19 @@ struct hb_serialize_context_t
}
template <typename Type>
Type *extend_size (Type &obj, size_t size)
{ return extend_size (hb_addressof (obj), size); }
{ return extend_size (std::addressof (obj), size); }
template <typename Type>
Type *extend_min (Type *obj) { return extend_size (obj, obj->min_size); }
template <typename Type>
Type *extend_min (Type &obj) { return extend_min (hb_addressof (obj)); }
Type *extend_min (Type &obj) { return extend_min (std::addressof (obj)); }
template <typename Type, typename ...Ts>
Type *extend (Type *obj, Ts&&... ds)
{ return extend_size (obj, obj->get_size (std::forward<Ts> (ds)...)); }
template <typename Type, typename ...Ts>
Type *extend (Type &obj, Ts&&... ds)
{ return extend (hb_addressof (obj), std::forward<Ts> (ds)...); }
{ return extend (std::addressof (obj), std::forward<Ts> (ds)...); }
/* Output routines. */
hb_bytes_t copy_bytes () const