From dbf7c5fdfa85ec26555ac9c823aae25cb79a6fdd Mon Sep 17 00:00:00 2001 From: matteokeole Date: Sat, 22 Nov 2025 19:21:07 +0100 Subject: [PATCH 1/2] feat: Compile-time variant of std::strlen --- Base/Utilities.hpp | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/Base/Utilities.hpp b/Base/Utilities.hpp index 37dd60f..d093e9e 100644 --- a/Base/Utilities.hpp +++ b/Base/Utilities.hpp @@ -1,4 +1,4 @@ -// Copyright 2025 Atalante. +// Copyright 2025 Atalante. // Licensed under MIT. #pragma once @@ -9,17 +9,15 @@ namespace atl { std::copy(sourceBegin, sourceEnd, destination); } - inline uint64 countCharacters(const char8* string) { - uint64 count = 0; - - while (true) { - if (string[count] == '\0') { - break; + inline constexpr uint64 countCharacters(const char8* characters) { + #if ATL_STANDARD >= ATL_STANDARD_CPP17 + return std::char_traits::length(characters); + #else + if (*characters == '\0') { + return 0; } - count += 1; - } - - return count; + return 1 + countCharacters(characters + 1); + #endif } } \ No newline at end of file From 4607e3b9fde4ec5311706fc714daf5e6f3385cb9 Mon Sep 17 00:00:00 2001 From: matteokeole Date: Sat, 22 Nov 2025 19:21:43 +0100 Subject: [PATCH 2/2] feat: Allow view to be constructed from constexpr char8* --- Base/Types/view.hpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Base/Types/view.hpp b/Base/Types/view.hpp index 5dad244..5052c63 100644 --- a/Base/Types/view.hpp +++ b/Base/Types/view.hpp @@ -17,9 +17,8 @@ namespace atl { public: using base_view::base_view; - // TODO: Add support for versions below C++17. - ATL_CONSTEXPR_CPP17 view(const char8* data) : - view(data, std::char_traits::length(data)) + constexpr view(const char8* data) : + view(data, countCharacters(data)) {} uint64 find(char8 character, uint64 characterOffset) const {