From 7fae2278232bb718d44547168fe107d6bf883311 Mon Sep 17 00:00:00 2001 From: Nana Sakisaka <1901813+saki7@users.noreply.github.com> Date: Sun, 9 Aug 2026 14:13:11 +0900 Subject: [PATCH] Add string_view support for `fixed_value` constructors --- include/iris/x4/attribute/value.hpp | 14 ++++++++++++++ test/x4/value.cpp | 4 ++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/include/iris/x4/attribute/value.hpp b/include/iris/x4/attribute/value.hpp index 30f296595..2f89cdeee 100644 --- a/include/iris/x4/attribute/value.hpp +++ b/include/iris/x4/attribute/value.hpp @@ -146,6 +146,20 @@ struct fixed_value_gen return fixed_value_parser>{std::forward(value)}; } + [[nodiscard]] static constexpr fixed_value_parser + operator()(std::string_view value) + noexcept(std::is_nothrow_constructible_v, std::string_view>) + { + return fixed_value_parser{value}; + } + + [[nodiscard]] static constexpr fixed_value_parser + operator()(std::u32string_view value) + noexcept(std::is_nothrow_constructible_v, std::u32string_view>) + { + return fixed_value_parser{value}; + } + template [[nodiscard]] static constexpr string_array_attr_parser_t operator()(CharArrayT&& char_array) diff --git a/test/x4/value.cpp b/test/x4/value.cpp index d6ac989a5..8eb67ea39 100644 --- a/test/x4/value.cpp +++ b/test/x4/value.cpp @@ -71,7 +71,7 @@ TEST_CASE("attr") } { [[maybe_unused]] constexpr auto attr_p = fixed_value("foo"sv); - STATIC_CHECK(std::same_as, x4::fixed_value_parser>>); + STATIC_CHECK(std::same_as, x4::fixed_value_parser, std::basic_string_view>>); } { @@ -84,7 +84,7 @@ TEST_CASE("attr") } { [[maybe_unused]] constexpr auto attr_p = fixed_value(U"foo"sv); - STATIC_CHECK(std::same_as, x4::fixed_value_parser>>); + STATIC_CHECK(std::same_as, x4::fixed_value_parser, std::basic_string_view>>); } IRIS_X4_ASSERT_CONSTEXPR_CTORS(fixed_value(1));