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
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ endif()

project(iris_x4 VERSION 1.0.0 LANGUAGES CXX)

set(CMAKE_CXX_SCAN_FOR_MODULES OFF)

# -----------------------------------------------------------------
# Load Iris
Expand Down
1 change: 0 additions & 1 deletion include/iris/x4/attribute/value.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ struct fixed_value_parser : parser<fixed_value_parser<T, HeldValueT>>
{
static_assert(X4Attribute<T>);
static_assert(!X4UnusedAttribute<T>, "fixed_value_parser with `unused_type` is meaningless");
static_assert(X4Movable<HeldValueT const&, T>);

// `HeldValueT` is almost always equal to `T`.
//
Expand Down
28 changes: 15 additions & 13 deletions include/iris/x4/core/action.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@
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/attribute.hpp>
#include <iris/x4/core/parser.hpp>
#include <iris/x4/core/context.hpp>
#include <iris/x4/core/action_context.hpp>

#include <iris/type_traits.hpp>

#include <iterator>
#include <concepts>
#include <type_traits>
Expand Down Expand Up @@ -49,9 +51,9 @@ struct action_context<Context, Attr>
// Ideally we should have a context-agnostic concept that can be used
// like `X4ActionFunctor<F>`, but we technically can't.
//
// In order to check `std::invocable`, we need to know the actual context
// type passed to the `.parse(...)` function but it is unknown until
// runtime.
// In order to check whether it is invocable, we need to know the actual
// context type passed to the `.parse(...)` function, but it is unknown
// until runtime.
//
// Even if we make up the most trivial context type (i.e. `unused_type`),
// such concept will be useless because a user-provided functor always
Expand Down Expand Up @@ -154,18 +156,18 @@ struct action : proxy_parser<action<Subject, ActionF>, Subject>
template<class Context, X4Attribute Attr>
[[nodiscard]] constexpr bool
call_action(Context const&, Attr&) const
noexcept(std::is_nothrow_invocable_v<ActionF const&>)
noexcept(is_nothrow_directly_invocable_v<ActionF const&>)
{
// Explicitly make this hard error instead of emitting "no matching overload".
// This provides much more human-friendly errors.
static_assert(
std::invocable<ActionF const&>,
directly_invocable<ActionF const&>,
"Neither `f(ctx)` nor `f()` is well-formed for your semantic action. "
"Check your function signature. Note that some functors might need "
"`const` qualifier to satisfy the constraints."
);

using action_return_type = std::invoke_result_t<ActionF const&>;
using action_return_type = directly_invoke_result_t<ActionF const&>;
constexpr bool action_returns_bool = std::same_as<action_return_type, bool>;
static_assert(
action_returns_bool || std::same_as<action_return_type, void>,
Expand All @@ -182,12 +184,12 @@ struct action : proxy_parser<action<Subject, ActionF>, Subject>

// Semantic action with parameter: `p[([](auto&& ctx) { /* ... */ })]`
template<class Context, X4Attribute Attr>
requires std::invocable<ActionF const&, typename detail::action_context<Context, Attr>::type>
requires directly_invocable<ActionF const&, typename detail::action_context<Context, Attr>::type>
[[nodiscard]] constexpr bool
call_action(Context const& ctx, Attr& attr) const
noexcept(std::is_nothrow_invocable_v<ActionF const&, typename detail::action_context<Context, Attr>::type>)
noexcept(is_nothrow_directly_invocable_v<ActionF const&, typename detail::action_context<Context, Attr>::type>)
{
using action_return_type = std::invoke_result_t<ActionF const&, typename detail::action_context<Context, Attr>::type>;
using action_return_type = directly_invoke_result_t<ActionF const&, typename detail::action_context<Context, Attr>::type>;
constexpr bool action_returns_bool = std::same_as<action_return_type, bool>;
static_assert(
action_returns_bool || std::same_as<action_return_type, void>,
Expand Down Expand Up @@ -215,13 +217,13 @@ struct action : proxy_parser<action<Subject, ActionF>, Subject>

template<class Context, X4Attribute Attr>
requires
(!std::invocable<ActionF const&, typename detail::action_context<Context, Attr>::type>) &&
std::invocable<ActionF const&, typename detail::action_context<Context, Attr>::type const&>
(!directly_invocable<ActionF const&, typename detail::action_context<Context, Attr>::type>) &&
directly_invocable<ActionF const&, typename detail::action_context<Context, Attr>::type const&>
static constexpr bool
call_action(Context const&, Attr&)
{
static_assert(
std::invocable<ActionF const&, typename detail::action_context<Context, Attr>::type>,
directly_invocable<ActionF const&, typename detail::action_context<Context, Attr>::type>,
"Semantic action expecting non-const lvalue reference context is obsolete. Use `auto&& ctx` and avoid using `auto& ctx`."
);
return false; // dummy
Expand Down
2 changes: 1 addition & 1 deletion include/iris/x4/core/context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ concept ContextNextType =
!std::is_lvalue_reference_v<Next> &&
!std::is_rvalue_reference_v<Next> &&
!std::is_const_v<Next> &&
std::move_constructible<Next>
std::is_move_constructible_v<Next>
)
);

Expand Down
2 changes: 1 addition & 1 deletion include/iris/x4/core/detail/parse_into_container.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ struct parse_into_container_impl_default
static constexpr bool call(Parser const& parser, It& first, Se const& last, Context& ctx, Attr& attr)
// never noexcept (requires container insertion)
{
using unwrapped_attribute_type = iris::unwrap_recursive_type<Attr>;
using unwrapped_attribute_type = iris::unwrap_recursive_t<Attr>;
auto& unwrapped_attr = iris::unwrap_recursive(attr);

if constexpr (traits::is_container_v<unwrapped_attribute_type>) { // Attr is a container
Expand Down
8 changes: 4 additions & 4 deletions include/iris/x4/core/list_like_parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,18 @@ template<X4NonUnusedAttribute ParserAttr, X4NonUnusedAttribute ExposedAttr>
struct unwrap_container_candidate
{
using type = traits::synthesized_value<
unwrap_recursive_type<
unwrap_recursive_t<
typename unwrap_container_appender<ExposedAttr>::type
>
>::type;
};

template<X4NonUnusedAttribute ParserAttr, X4NonUnusedAttribute ExposedVariant>
requires traits::is_variant_v<unwrap_recursive_type<ExposedVariant>>
requires traits::is_variant_v<unwrap_recursive_t<ExposedVariant>>
struct unwrap_container_candidate<ParserAttr, ExposedVariant>
{
using type = traits::variant_find_holdable_type<
unwrap_recursive_type<ExposedVariant>, ParserAttr
unwrap_recursive_t<ExposedVariant>, ParserAttr
>::type;
};

Expand Down Expand Up @@ -89,7 +89,7 @@ template<X4NonUnusedAttribute ParserAttr, X4NonUnusedAttribute ExposedAttr>
[[nodiscard]] constexpr auto& get_container(ExposedAttr& attr)
{
using unwrapped_attr_type = detail::unwrap_single_element_plain<
unwrap_recursive_type<ExposedAttr>
unwrap_recursive_t<ExposedAttr>
>::type;
auto& unwrapped_attr = detail::unwrap_single_element(iris::unwrap_recursive(attr));

Expand Down
11 changes: 3 additions & 8 deletions include/iris/x4/core/move_to.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
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/char_traits.hpp>

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

#include <iris/alloy/tuple.hpp>
#include <iris/alloy/tuple.hpp> // IWYU pragma: keep
#include <iris/alloy/utility.hpp>

#include <iterator>
Expand Down Expand Up @@ -265,7 +265,7 @@ move_to(Source&& src, Dest& dest)
{
static_assert(!std::same_as<std::remove_cvref_t<Source>, Dest>, "[BUG] This call should instead resolve to the overload handling identical types");

if constexpr (std::constructible_from<typename traits::container_value<Dest>::type, Source>) {
if constexpr (std::is_constructible_v<typename traits::container_value<Dest>::type, Source>) {
traits::push_back(dest, std::forward<Source>(src));
} else {
if constexpr (std::is_rvalue_reference_v<Source&&>) {
Expand All @@ -288,11 +288,6 @@ move_to(Source&& src, Dest& dest)
x4::move_to(std::forward<Source>(src), alloy::get<0>(dest));
}

template<class Source, class Dest>
concept X4Movable = requires {
x4::move_to(std::declval<Source>(), std::declval<Dest&>());
};

} // iris::x4

#endif
4 changes: 2 additions & 2 deletions include/iris/x4/core/parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ struct parser
static constexpr bool requires_exact_attribute_type = false;

template<class Self, class Action>
requires std::constructible_from<
requires std::is_constructible_v<
action<std::remove_cvref_t<Self>, std::remove_cvref_t<Action>>,
Self, Action
>
Expand All @@ -82,7 +82,7 @@ struct parser
}

template<class Self, class Action>
requires std::constructible_from<
requires std::is_constructible_v<
action<std::remove_cvref_t<Self>, std::remove_cvref_t<Action>>,
Self, Action
>
Expand Down
8 changes: 4 additions & 4 deletions include/iris/x4/traits/variant_traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ struct any_of_unwrapped_exactly_same<T>
{};

template<class T, class First, class... Rest>
requires std::same_as<T, iris::unwrap_recursive_type<First>>
requires std::same_as<T, iris::unwrap_recursive_t<First>>
struct any_of_unwrapped_exactly_same<T, First, Rest...>
: std::true_type
{};

template<class T, class First, class... Rest>
requires (!std::same_as<T, iris::unwrap_recursive_type<First>>)
requires (!std::same_as<T, iris::unwrap_recursive_t<First>>)
struct any_of_unwrapped_exactly_same<T, First, Rest...>
: any_of_unwrapped_exactly_same<T, Rest...>
{};
Expand All @@ -68,7 +68,7 @@ template<class T, class First, class... Rest>
struct variant_find_holdable_type_impl<T, First, Rest...>
{
using type = std::conditional_t<
can_hold<iris::unwrap_recursive_type<First>, T>::value,
can_hold<iris::unwrap_recursive_t<First>, T>::value,

// Given some type `T`, when both `T` and `recursive_wrapper<T>` is seen
// during attribute resolution, X4 should ideally materialize the latter
Expand Down Expand Up @@ -109,7 +109,7 @@ template<class... Ts, class T>
requires (!std::same_as<iris::rvariant<Ts...>, T>) && (!detail::any_of_unwrapped_exactly_same<T, Ts...>::value)
struct variant_find_holdable_type<iris::rvariant<Ts...>, T>
{
using type = typename detail::variant_find_holdable_type_impl<T, Ts...>::type;
using type = detail::variant_find_holdable_type_impl<T, Ts...>::type;
};

} // iris::x4::traits
Expand Down
1 change: 0 additions & 1 deletion test/x4/move_to.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ TEST_CASE("move_to")
//XYZ xyz;
//xyz = std::vector<X>{};
static_assert(!std::is_assignable_v<XYZ&, std::vector<X>>);
STATIC_CHECK(!x4::X4Movable<std::vector<X>, XYZ>);
}

// tuple contains reference
Expand Down
Loading