Merge pull request #92 from diamante0018/main

maint(utils): use constexpr c++20 function instead of macro
This commit is contained in:
Maurice Heumann 2022-12-27 10:30:58 +01:00 committed by GitHub
commit 210f69db31

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)