maint(utils): use constexpr c++20 function instead of macro

This commit is contained in:
Diavolo 2022-12-27 10:25:24 +01:00
parent bf9ad44ab0
commit b8fecbc12b

View File

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