Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions Base/Types/view.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ namespace atl {
public:
using base_view<char8>::base_view;

// TODO: Add support for versions below C++17.
ATL_CONSTEXPR_CPP17 view<char8>(const char8* data) :
view<char8>(data, std::char_traits<char8>::length(data))
constexpr view<char8>(const char8* data) :
view<char8>(data, countCharacters(data))
{}

uint64 find(char8 character, uint64 characterOffset) const {
Expand Down
20 changes: 9 additions & 11 deletions Base/Utilities.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2025 Atalante.
// Copyright 2025 Atalante.
// Licensed under MIT.

#pragma once
Expand All @@ -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<char8>::length(characters);
#else
if (*characters == '\0') {
return 0;
}

count += 1;
}

return count;
return 1 + countCharacters(characters + 1);
#endif
}
}
Loading