Avoiding __builtin_strlen (#4429)

This commit is contained in:
Barry Revzin
2025-04-27 11:32:10 -05:00
committed by GitHub
parent c936e2e44e
commit 8978ab09b2
2 changed files with 24 additions and 1 deletions

View File

@ -92,6 +92,29 @@ TEST(string_view_test, compare) {
check_op<std::greater_equal>();
}
#if FMT_USE_CONSTEVAL
namespace {
template <size_t N>
struct fixed_string {
char data[N] = {};
constexpr fixed_string(char const (&m)[N]) {
for (size_t i = 0; i != N; ++i) {
data[i] = m[i];
}
}
};
}
TEST(string_view_test, from_constexpr_fixed_string) {
static constexpr auto fs = fixed_string<5>("x={}");
static constexpr auto fmt = fmt::string_view(fs.data);
EXPECT_EQ(fmt, "x={}");
}
#endif
TEST(base_test, is_locking) {
EXPECT_FALSE(fmt::detail::is_locking<const char(&)[3]>());
}