maint(string): use c++20 constexpr (#559)

This commit is contained in:
Edo 2022-12-24 21:59:26 +01:00 committed by GitHub
parent 64178c588b
commit c6cf4fe4b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,10 +2,8 @@
#include "memory.hpp"
#include <cstdint>
#ifndef ARRAYSIZE
template <class Type, size_t n>
size_t ARRAYSIZE(Type (&)[n]) { return n; }
#endif
constexpr auto ARRAY_COUNT(Type(&)[n]) { return n; }
namespace utils::string
{
@ -21,7 +19,7 @@ namespace utils::string
char* get(const char* format, const va_list ap)
{
++this->current_buffer_ %= ARRAYSIZE(this->string_pool_);
++this->current_buffer_ %= ARRAY_COUNT(this->string_pool_);
auto entry = &this->string_pool_[this->current_buffer_];
if (!entry->size || !entry->buffer)