stratosphere: fix call to non-constexpr strlen in constexpr function

strlen being constexpr is a non-compliant GCC extension; Clang
explicitly rejects it: https://reviews.llvm.org/D23692
This commit is contained in:
Léo Lam 2021-11-05 15:54:55 +01:00
commit 16e738ece2
No known key found for this signature in database
GPG key ID: 0DF30F9081000741
2 changed files with 4 additions and 8 deletions

View file

@ -62,18 +62,14 @@ namespace ams::settings {
char name[MaxLength];
static constexpr LanguageCode Encode(const char *name, size_t name_size) {
static constexpr LanguageCode Encode(util::string_view name) {
LanguageCode out{};
for (size_t i = 0; i < MaxLength && i < name_size; i++) {
for (size_t i = 0; i < MaxLength && i < name.size(); i++) {
out.name[i] = name[i];
}
return out;
}
static constexpr LanguageCode Encode(const char *name) {
return Encode(name, std::strlen(name));
}
template<Language Lang>
static constexpr inline LanguageCode EncodeLanguage = [] {
if constexpr (false) { /* ... */ }

View file

@ -40,8 +40,8 @@ namespace ams::sm {
return out;
}
static constexpr ServiceName Encode(const char *name) {
return Encode(name, std::strlen(name));
static constexpr ServiceName Encode(util::string_view name) {
return Encode(name.data(), name.size());
}
};