Move hb_addressof() to hb-meta.hh

This commit is contained in:
Behdad Esfahbod 2019-01-28 21:26:23 -05:00
parent 6cf25c2971
commit e75b22039f
4 changed files with 14 additions and 15 deletions

View File

@ -271,18 +271,6 @@ hb_ctz (T v)
* Tiny stuff.
*/
template <typename T> static inline T*
hb_addressof (const T& arg)
{
#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
}
/* ASCII tag/character handling */
static inline bool ISALPHA (unsigned char c)
{ return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'); }

View File

@ -28,7 +28,6 @@
#define HB_ITER_HH
#include "hb.hh"
#include "hb-algs.hh" // for hb_addressof
#include "hb-meta.hh"

View File

@ -31,10 +31,22 @@
/*
* C++ Template Meta-programming.
* C++ template meta-programming & fundamentals used with them.
*/
template <typename T> static inline T*
hb_addressof (const T& arg)
{
#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
}
template <typename T> static inline T hb_declval ();
#define hb_declval(T) (hb_declval<T> ())

View File

@ -639,7 +639,7 @@ _hb_memalign(void **memptr, size_t alignment, size_t size)
#include "hb-atomic.hh" // Requires: hb-meta
#include "hb-null.hh" // Requires: hb-meta
#include "hb-algs.hh" // Requires: hb-null
#include "hb-iter.hh" // Requires: hb-algs hb-meta
#include "hb-iter.hh" // Requires: hb-meta
#include "hb-debug.hh" // Requires: hb-algs hb-atomic
#include "hb-array.hh" // Requires: hb-algs hb-iter hb-null
#include "hb-vector.hh" // Requires: hb-array hb-null