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
3 changes: 1 addition & 2 deletions include/iris/x4/attribute/as.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,7 @@ struct as_type_parser : unary_parser<Subject, as_type_parser<T, Subject>>
// `outer_parser<U>(as<T>(subject))` forwards temporary `T` local variable for the subject, then move the variable to `U&`
template<std::forward_iterator It, std::sentinel_for<It> Se, class Context, X4NonUnusedAttribute OuterAttr>
requires
(!std::same_as<std::remove_const_t<OuterAttr>, T>) &&
X4Movable<T, OuterAttr>
(!std::same_as<std::remove_const_t<OuterAttr>, T>)
[[nodiscard]] constexpr bool
parse(It& first, Se const& last, Context const& ctx, OuterAttr& outer_attr) const
noexcept(
Expand Down
4 changes: 2 additions & 2 deletions include/iris/x4/core/action.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ struct action : proxy_parser<Subject, action<Subject, ActionF>>
noexcept(this->parse_main(first, last, ctx, std::declval<typename base_type::attribute_type&>()))
)
{
typename base_type::attribute_type attr_temp; // default-initialize
typename base_type::attribute_type attr_temp{}; // value-initialize
return this->parse_main(first, last, ctx, attr_temp);
}

Expand Down Expand Up @@ -138,7 +138,7 @@ struct action : proxy_parser<Subject, action<Subject, ActionF>>
noexcept(this->parse_main(first, last, ctx, std::declval<typename base_type::attribute_type&>()))
)
{
typename base_type::attribute_type attr_temp; // default-initialize
typename base_type::attribute_type attr_temp{}; // value-initialize
return this->parse_main(first, last, ctx, attr_temp);
}

Expand Down
16 changes: 14 additions & 2 deletions include/iris/x4/directive/with.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,8 @@ using parsers::directive::with;
template<class Subject, class... IDs>
struct without_directive : proxy_parser<Subject, without_directive<Subject, IDs...>>
{
static_assert(sizeof...(IDs) > 0);

template<std::forward_iterator It, std::sentinel_for<It> Se, class Context, X4Attribute Attr>
[[nodiscard]] constexpr bool
parse(It& first, Se const& last, Context const& ctx, Attr& attr) const
Expand All @@ -258,9 +260,19 @@ namespace detail {
template<class... IDs>
struct without_gen
{
// `without<>(p)` is no-op
template<class Subject>
requires (sizeof...(IDs) == 0)
[[nodiscard]] static constexpr auto&&
operator[](Subject&& subject IRIS_LIFETIMEBOUND) noexcept
{
return static_cast<Subject&&>(subject);
}

template<class Subject>
[[nodiscard]] constexpr without_directive<std::remove_cvref_t<Subject>, IDs...>
operator[](Subject&& subject) const // TODO: MSVC 2022 does not properly handle static operator[]
requires (sizeof...(IDs) > 0)
[[nodiscard]] static constexpr without_directive<std::remove_cvref_t<Subject>, IDs...>
operator[](Subject&& subject)
noexcept(std::is_nothrow_constructible_v<without_directive<std::remove_cvref_t<Subject>, IDs...>, Subject>)
{
return without_directive<std::remove_cvref_t<Subject>, IDs...>{
Expand Down
Loading