Commit Graph
12 Commits
Author SHA1 Message Date
Behdad EsfahbodandEbrahim c956a11cc7 [algs] Unify ARRAY_LENGTH with compile-time type information (#6539)
* [algs] Declare ARRAY_LENGTH also constexpr so can be used in static contexts

* [algs] Remove more use of ARRAY_LENGTH_CONST

And rename it to ARRAY_LENGTH_UNCHECKED so it will be more obvious
this is the last resort.

* [bit] Avoid use of ARRAY_LENGTH_UNCHECKED

* [algs] Move ARRAY_LENGTH_UNCHECKED to its only caller

* [algs] Return size_t from ARRAY_LENGTH

* [algs] Remove last use of ARRAY_LENGTH_UNCHECKED

* [algs] Use std::extent to get template parameter array length

It makes more sense I think.

* [algs] Make ARRAY_LENGTH usable through template reference parameters

Evaluating ARRAY_LENGTH on a reference parameter is not a constant
expression in C++11. Return std::integral_constant from a function
object so callers can extract the length from the return type without
evaluating the array expression. Ordinary calls still convert to size_t.

Use this form for all three Arabic fallback ligature table dimensions,
replacing std::extent. Document both forms and add compile-time checks
for ordinary calls, string literals, and nested template array arguments.

Validated with GCC and Clang C++11 syntax checks, a full Meson build,
and meson test -C build (296 passed, 1 skipped).

Assisted-by: OpenAI Codex

---------

Co-authored-by: Ebrahim <ebrahim@gnu.org>
2026-11-01 09:48:25 -07:00
Behdad Esfahbod 06e9277fa3 Rename _S to HB_STR
Fixes https://github.com/harfbuzz/harfbuzz/issues/5446
2025-08-07 22:38:58 -06:00
Michiharu Ariza 8fdafee2a6 undef HB_STRING_ARRAY_LENG_NAME 2019-11-19 01:13:00 -05:00
blueshade7 5e9863f3c6 ARRAY_LENGTH fails with -Wglobal-constructors 2019-11-19 01:13:00 -05:00
blueshade7 a75983690d calculate hb_string_array length automatically 2019-11-19 01:13:00 -05:00
Behdad Esfahbod 0e294c455e Rename VAR to HB_VAR_ARRAY 2019-09-06 16:54:27 -04:00
Behdad Esfahbod c77ae40852 Rename hb-*private.hh to hb-*.hh
Sorry for the noise, downstream custom builders.  Please adjust.
2018-08-25 22:36:36 -07:00
Behdad Esfahbod 08e280fd84 Rename hb_string_t to hb_bytes_t 2018-05-08 01:57:27 -07:00
Ebrahim Byagowi f24b0b9728 Update the links and revive the dead ones 2018-04-12 13:44:32 +04:30
Behdad Esfahbod 7fdf16b2ce Fix compiler warning 2017-11-14 15:04:19 -08:00
Behdad Esfahbod 6c738f353e Make string-array return hb_string_t 2017-10-30 12:21:44 -06:00
Behdad Esfahbod 2a74968044 Add hb-string-array.hh
Used to build static string arrays that use no relocation.
2017-10-26 20:32:16 -06:00