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
12 changes: 6 additions & 6 deletions include/iris/x4/allocator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ template<class Klass>
struct allocator_ops
{
template<class... Allocs>
static constexpr bool move_assign_noexcept = std::conjunction_v<
std::disjunction<
typename std::allocator_traits<Allocs>::propagate_on_container_move_assignment,
typename std::allocator_traits<Allocs>::is_always_equal
>...
>;
static constexpr bool move_assign_noexcept = (
(
std::allocator_traits<Allocs>::propagate_on_container_move_assignment::value ||
std::allocator_traits<Allocs>::is_always_equal::value
) && ...
);

template<auto AllocMem, auto Mem>
[[nodiscard]] static constexpr auto copy_construct(Klass& self, Klass const& other)
Expand Down
1 change: 1 addition & 0 deletions include/iris/x4/core/context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

#include <iris/config.hpp>
#include <iris/type_traits.hpp>
#include <iris/type_list.hpp>

#include <iris/x4/core/unused.hpp>

Expand Down
4 changes: 2 additions & 2 deletions include/iris/x4/core/detail/parse_alternative.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ struct pass_non_variant_attribute
}
};

// Unwrap single element sequences
// Unwrap single-element tuple-likes
template<class Parser, X4Attribute Attr>
requires tuple_is_size_one_sequence_v<Attr>
requires SingleElementTupleLike<Attr>
struct pass_non_variant_attribute<Parser, Attr>
{
using attr_type = std::remove_reference_t<
Expand Down
10 changes: 6 additions & 4 deletions include/iris/x4/core/detail/parse_into_container.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@

#include <iris/x4/core/attribute.hpp>
#include <iris/x4/core/container_appender.hpp>
#include <iris/x4/core/parser_traits.hpp>

#include <iris/x4/traits/container_traits.hpp>
#include <iris/x4/core/traits/tuple_traits.hpp>
#include <iris/x4/core/traits/variant_traits.hpp>

#include <iris/alloy/tuple.hpp>

Expand Down Expand Up @@ -83,11 +85,11 @@ struct parse_into_container_impl_default
}

} else {
if constexpr (tuple_is_size_one_sequence_v<unwrapped_attribute_type>) {
// attribute is single element tuple-like; unwrap and try again
if constexpr (SingleElementTupleLike<unwrapped_attribute_type>) {
// attribute is a single-element tuple-like; unwrap and try again
return parse_into_container_impl_default<Parser>::call(parser, first, last, ctx, alloy::get<0>(unwrapped_attr));
} else {
static_assert(false, "[BUG] parse_into_container accepts a container, a variant of container or a single element tuple-like of container");
static_assert(false, "[BUG] parse_into_container accepts a container, a variant of container or a single-element tuple-like of container");
return false;
}
}
Expand All @@ -110,7 +112,7 @@ parse_into_container(Parser const& parser, It& first, Se const& last, Context co
} else if constexpr (is_recursive_wrapper_v<Attr>) {
return detail::parse_into_container(parser, first, last, ctx, *attr);

} else if constexpr (tuple_is_size_one_sequence_v<Attr>) {
} else if constexpr (SingleElementTupleLike<Attr>) {
// A tuple-like holding a single container; parse into that container
return detail::parse_into_container(parser, first, last, ctx, alloy::get<0>(attr));

Expand Down
6 changes: 3 additions & 3 deletions include/iris/x4/core/detail/parse_sequence.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ struct parse_sequence_tuple
if constexpr (I != layout::single_attributed_index) {
return elem.parse(first, last, ctx, unused);

} else if constexpr (tuple_is_size_one_view_v<Attr> && !sequence_passes_view<parser_type>::value) {
} else if constexpr (SingleElementTupleLikeView<Attr> && !sequence_passes_view<parser_type>::value) {
auto&& elem_attr = x4::make_container_appender(alloy::get<0>(attr));
return elem.parse(first, last, ctx, elem_attr);

Expand Down Expand Up @@ -232,10 +232,10 @@ struct parse_into_container_impl<sequence<Ps...>>
)
{
if constexpr (traits::is_container_v<Attr>) {
constexpr bool sequence_attribute_can_directly_hold_value_type = can_hold<
constexpr bool sequence_attribute_can_directly_hold_value_type = can_hold_v<
typename parser_traits<sequence<Ps...>>::attribute_type,
typename traits::container_value<Attr>::type
>::value;
>;

if constexpr (sequence_attribute_can_directly_hold_value_type) {
return parse_into_container_impl_default<sequence<Ps...>>::call(seq, first, last, ctx, attr);
Expand Down
36 changes: 4 additions & 32 deletions include/iris/x4/core/list_like_parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ template<X4NonUnusedAttribute ParserAttr, X4NonUnusedAttribute ExposedAttr>
// non-variant `ExposedAttr`
struct unwrap_container_candidate
{
using type = synthesized_value<
using type = unwrap_single_element_t<
unwrap_recursive_t<
typename unwrap_container_appender<ExposedAttr>::type
>
>::type;
>;
};

template<X4NonUnusedAttribute ParserAttr, X4NonUnusedAttribute ExposedVariant>
Expand All @@ -52,32 +52,6 @@ struct chunk_buffer_impl
static_assert(traits::X4Container<typename unwrap_container_candidate<ParserAttr, ExposedAttr>::type>);
};

template<class T>
[[nodiscard]] constexpr auto&& unwrap_single_element(T&& value) noexcept
{
return std::forward<T>(value);
}

template<class T>
requires tuple_is_size_one_sequence_v<std::remove_cvref_t<T>>
[[nodiscard]] constexpr auto&& unwrap_single_element(T&& value) noexcept
{
return std::forward_like<T>(alloy::get<0>(std::forward<T>(value)));
}

template<class T>
struct unwrap_single_element_plain
{
using type = std::remove_cvref_t<T>;
};

template<class T>
requires tuple_is_size_one_sequence_v<std::remove_cvref_t<T>>
struct unwrap_single_element_plain<T>
{
using type = std::remove_cvref_t<alloy::tuple_element_t<0, T>>;
};

} // detail


Expand All @@ -88,10 +62,8 @@ using chunk_buffer = detail::chunk_buffer_impl<ParserAttr, ExposedAttr>::type;
template<X4NonUnusedAttribute ParserAttr, X4NonUnusedAttribute ExposedAttr>
[[nodiscard]] constexpr auto& get_container(ExposedAttr& attr)
{
using unwrapped_attr_type = detail::unwrap_single_element_plain<
unwrap_recursive_t<ExposedAttr>
>::type;
auto& unwrapped_attr = detail::unwrap_single_element(iris::unwrap_recursive(attr));
using unwrapped_attr_type = unwrap_single_element_t<unwrap_recursive_t<ExposedAttr>>;
auto& unwrapped_attr = x4::unwrap_single_element(iris::unwrap_recursive(attr));

if constexpr (is_variant_v<unwrapped_attr_type>) {
using container_alternative = variant_find_holdable_type<
Expand Down
16 changes: 8 additions & 8 deletions include/iris/x4/core/move_to.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ constexpr void move_to(It const&, Se const&, unused_type const&&) = delete; // t
// Category specific --------------------------------------

template<NonUnusedCategorizedAttr Source, CategorizedAttr<plain_tag> Dest>
requires tuple_is_size_one_sequence_v<Source>
requires SingleElementTupleLike<Source>
constexpr void
move_to(Source&& src, Dest& dest)
noexcept(noexcept(dest = std::forward_like<Source>(alloy::get<0>(std::forward<Source>(src)))))
Expand All @@ -126,7 +126,7 @@ move_to(Source&& src, Dest& dest)
}

template<NonUnusedCategorizedAttr Source, CategorizedAttr<plain_tag> Dest>
requires (!tuple_is_size_one_sequence_v<Source>)
requires (!SingleElementTupleLike<Source>)
constexpr void
move_to(Source&& src, Dest& dest)
noexcept(std::is_nothrow_assignable_v<Dest&, Source&&>)
Expand All @@ -140,8 +140,8 @@ move_to(Source&& src, Dest& dest)

template<NonUnusedCategorizedAttr Source, CategorizedAttr<tuple_tag> Dest>
requires
tuple_is_same_size_sequence_v<Dest, Source> &&
(!tuple_is_size_one_sequence_v<Dest>)
SameSizeTupleLike<Dest, Source> &&
(!SingleElementTupleLike<Dest>)
constexpr void
move_to(Source&& src, Dest& dest)
noexcept(noexcept(alloy::tuple_assign(std::forward<Source>(src), dest)))
Expand All @@ -167,7 +167,7 @@ move_to(Source&& src, Dest& dest)
}

template<NonUnusedCategorizedAttr Source, CategorizedAttr<variant_tag> Dest>
requires (!std::is_assignable_v<Dest&, Source&&>) && tuple_is_size_one_sequence_v<Source>
requires (!std::is_assignable_v<Dest&, Source&&>) && SingleElementTupleLike<Source>
constexpr void
move_to(Source&& src, Dest& dest)
noexcept(noexcept(dest = std::forward_like<Source>(alloy::get<0>(std::forward<Source>(src)))))
Expand Down Expand Up @@ -229,7 +229,7 @@ move_to(It first, Se last, Dest& dest)
}

template<std::forward_iterator It, std::sentinel_for<It> Se, CategorizedAttr<tuple_tag> Dest>
requires tuple_is_size_one_sequence_v<Dest>
requires SingleElementTupleLike<Dest>
constexpr void
move_to(It first, Se last, Dest& dest)
noexcept(noexcept(x4::move_to(first, last, alloy::get<0>(dest))))
Expand Down Expand Up @@ -274,9 +274,9 @@ move_to(Source&& src, Dest& dest)
}
}

// Size-one tuple-like forwarding
// Single-element tuple-like forwarding
template<NonUnusedCategorizedAttr Source, CategorizedAttr<tuple_tag> Dest>
requires tuple_is_size_one_sequence_v<Dest>
requires SingleElementTupleLike<Dest>
constexpr void
move_to(Source&& src, Dest& dest)
noexcept(noexcept(x4::move_to(std::forward<Source>(src), alloy::get<0>(dest))))
Expand Down
12 changes: 8 additions & 4 deletions include/iris/x4/core/parser_traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,7 @@ struct get_attribute_type<Parser>
template<class Parser, class Container>
struct get_handles_container
{
static constexpr bool value = can_hold<
typename get_attribute_type<Parser>::type,
Container
>::value;
static constexpr bool value = can_hold_v<Container, typename get_attribute_type<Parser>::type>;
};

template<class Parser, class Container>
Expand Down Expand Up @@ -139,6 +136,13 @@ struct parser_traits
static constexpr bool need_rcontext = Parser::need_rcontext;
};

// `Parser` writes into `Container`: it fills the container itself, or yields
// one element of it
template<class Parser, class Container>
concept WritesIntoContainer =
parser_traits<Parser>::template handles_container<Container> ||
can_hold_v<typename traits::container_value<Container>::type, typename parser_traits<Parser>::attribute_type>;

} // iris::x4

#endif
4 changes: 2 additions & 2 deletions include/iris/x4/core/skip_over.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/

#include <iris/config.hpp>
#include <iris/config.hpp> // IWYU pragma: keep

#include <iris/x4/core/unused.hpp>
#include <iris/x4/core/context.hpp>
#include <iris/x4/core/parser.hpp>

#include <concepts>
#include <iterator>
#include <type_traits>

namespace iris::x4 {

Expand Down
3 changes: 2 additions & 1 deletion include/iris/x4/core/traits/attribute_category.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@

#include <iris/config.hpp> // IWYU pragma: keep

#include <iris/x4/core/attribute.hpp>
#include <iris/x4/traits/container_traits.hpp>
#include <iris/x4/core/traits/variant_traits.hpp>
#include <iris/x4/core/traits/variant_class.hpp>
#include <iris/x4/core/traits/optional_traits.hpp>

#include <iris/alloy/traits.hpp>
Expand Down
5 changes: 4 additions & 1 deletion include/iris/x4/core/traits/can_hold.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ template<class TTuple, class UTuple>
struct is_all_substitute_for_tuple : std::false_type {};

template<class TTuple, class UTuple>
requires tuple_is_same_size_sequence_v<TTuple, UTuple>
requires SameSizeTupleLike<TTuple, UTuple>
struct is_all_substitute_for_tuple<TTuple, UTuple> : is_all_substitute_for_tuple_impl<TTuple, UTuple> {};

template<class T, class U>
Expand Down Expand Up @@ -111,6 +111,9 @@ struct can_hold<T, T>
static_assert(X4Attribute<T>);
};

template<class T, class U>
inline constexpr bool can_hold_v = can_hold<T, U>::value;

} // iris::x4

#endif
2 changes: 2 additions & 0 deletions include/iris/x4/core/traits/char_encoding_traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

#include <iris/x4/char_encoding/standard.hpp>

#include <iris/string.hpp>

#ifndef IRIS_X4_NO_STANDARD_WIDE
# include <iris/x4/char_encoding/standard_wide.hpp>
#endif
Expand Down
Loading
Loading