From e75b22039f4129b5057f4b175c9e9d79634b1728 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 28 Jan 2019 21:26:23 -0500 Subject: [PATCH] Move hb_addressof() to hb-meta.hh --- src/hb-algs.hh | 12 ------------ src/hb-iter.hh | 1 - src/hb-meta.hh | 14 +++++++++++++- src/hb.hh | 2 +- 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/hb-algs.hh b/src/hb-algs.hh index d03906c4a..9b524c130 100644 --- a/src/hb-algs.hh +++ b/src/hb-algs.hh @@ -271,18 +271,6 @@ hb_ctz (T v) * Tiny stuff. */ -template 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( - &const_cast( - reinterpret_cast(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'); } diff --git a/src/hb-iter.hh b/src/hb-iter.hh index 532918280..93db59a9e 100644 --- a/src/hb-iter.hh +++ b/src/hb-iter.hh @@ -28,7 +28,6 @@ #define HB_ITER_HH #include "hb.hh" -#include "hb-algs.hh" // for hb_addressof #include "hb-meta.hh" diff --git a/src/hb-meta.hh b/src/hb-meta.hh index a9f9df98b..b58003638 100644 --- a/src/hb-meta.hh +++ b/src/hb-meta.hh @@ -31,10 +31,22 @@ /* - * C++ Template Meta-programming. + * C++ template meta-programming & fundamentals used with them. */ +template 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( + &const_cast( + reinterpret_cast(arg))); +#pragma GCC diagnostic pop +} + template static inline T hb_declval (); #define hb_declval(T) (hb_declval ()) diff --git a/src/hb.hh b/src/hb.hh index eb941bea4..a6e3667ca 100644 --- a/src/hb.hh +++ b/src/hb.hh @@ -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