From 939a52b7053ea122d9418545ed2d202a01790e7b Mon Sep 17 00:00:00 2001 From: Nana Sakisaka <1901813+saki7@users.noreply.github.com> Date: Tue, 24 Feb 2026 15:50:01 +0900 Subject: [PATCH] Fix `unused_container` propagation --- include/iris/x4/directive/raw.hpp | 6 +++--- include/iris/x4/operator/alternative.hpp | 9 +++------ include/iris/x4/operator/sequence.hpp | 7 +++---- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/include/iris/x4/directive/raw.hpp b/include/iris/x4/directive/raw.hpp index 8eb971d72..6c9e0465e 100644 --- a/include/iris/x4/directive/raw.hpp +++ b/include/iris/x4/directive/raw.hpp @@ -37,7 +37,7 @@ struct raw_directive : unary_parser> static constexpr bool handles_container = true; - template Se, class Context, X4Attribute Attr> + template Se, class Context, X4NonUnusedAttribute Attr> [[nodiscard]] constexpr bool parse(It& first, Se const& last, Context const& ctx, Attr& attr) const // never noexcept; construction of `std::ranges::subrange` is never noexcept @@ -53,9 +53,9 @@ struct raw_directive : unary_parser> return true; } - template Se, class Context> + template Se, class Context, X4UnusedAttribute UnusedAttr> [[nodiscard]] constexpr bool - parse(It& first, Se const& last, Context const& ctx, unused_type) const + parse(It& first, Se const& last, Context const& ctx, UnusedAttr const&) const noexcept(is_nothrow_parsable_v) { return this->subject.parse(first, last, ctx, unused); diff --git a/include/iris/x4/operator/alternative.hpp b/include/iris/x4/operator/alternative.hpp index 84a1a323a..d4f9b9b71 100644 --- a/include/iris/x4/operator/alternative.hpp +++ b/include/iris/x4/operator/alternative.hpp @@ -35,9 +35,9 @@ struct alternative : binary_parser> using binary_parser::binary_parser; - template Se, class Context> + template Se, class Context, X4UnusedAttribute UnusedAttr> [[nodiscard]] constexpr bool - parse(It& first, Se const& last, Context const& ctx, unused_type) const + parse(It& first, Se const& last, Context const& ctx, UnusedAttr const&) const noexcept( is_nothrow_parsable_v && is_nothrow_parsable_v @@ -58,7 +58,7 @@ struct alternative : binary_parser> // // You also should add test to `attribute.cpp`. - template Se, class Context, class Attr> + template Se, class Context, X4NonUnusedAttribute Attr> requires (!traits::X4Container) [[nodiscard]] constexpr bool parse(It& first, Se const& last, Context const& ctx, Attr& attr) const @@ -69,9 +69,6 @@ struct alternative : binary_parser> noexcept(x4::move_to(std::declval(), attr)) ) { - static_assert(!std::same_as, unused_type>); - static_assert(!std::same_as, unused_container_type>); - static_assert( std::default_initializable, "Attribute needs to be default-initializable to support rollback on failed parse attempt." diff --git a/include/iris/x4/operator/sequence.hpp b/include/iris/x4/operator/sequence.hpp index b2d95c11d..0b69a4509 100644 --- a/include/iris/x4/operator/sequence.hpp +++ b/include/iris/x4/operator/sequence.hpp @@ -38,9 +38,9 @@ struct sequence : binary_parser> using binary_parser::binary_parser; - template Se, class Context> + template Se, class Context, X4UnusedAttribute UnusedAttr> [[nodiscard]] constexpr bool - parse(It& first, Se const& last, Context const& ctx, unused_type) const + parse(It& first, Se const& last, Context const& ctx, UnusedAttr const&) const noexcept( std::is_nothrow_copy_assignable_v && is_nothrow_parsable_v && @@ -66,8 +66,7 @@ struct sequence : binary_parser> return false; } - template Se, class Context, class Attr> - requires (!std::same_as, unused_type>) + template Se, class Context, X4NonUnusedAttribute Attr> [[nodiscard]] constexpr bool parse(It& first, Se const& last, Context const& ctx, Attr& attr) const noexcept(noexcept(detail::parse_sequence(*this, first, last, ctx, attr)))