Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workaround for unexpanded builtins in experimental/meta #64

Merged
merged 2 commits into from
Jun 29, 2024
Merged
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
39 changes: 24 additions & 15 deletions libcxx/include/experimental/meta
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,8 @@ enum : unsigned {
__metafn_return_type_of,
};

consteval auto __workaround_expand_compiler_builtins(info type) -> info;

} // namespace detail

namespace __range_of_infos {
Expand Down Expand Up @@ -1621,15 +1623,15 @@ consteval auto type_is_nothrow_invocable_r(info type_result, info type,
}

consteval auto type_remove_const(info type) -> info {
return dealias(substitute(^remove_const_t, {type}));
return detail::__workaround_expand_compiler_builtins(dealias(substitute(^remove_const_t, {type})));
}

consteval auto type_remove_volatile(info type) -> info {
return dealias(substitute(^remove_volatile_t, {type}));
return detail::__workaround_expand_compiler_builtins(dealias(substitute(^remove_volatile_t, {type})));
}

consteval auto type_remove_cv(info type) -> info {
return dealias(substitute(^remove_cv_t, {type}));
return detail::__workaround_expand_compiler_builtins(dealias(substitute(^remove_cv_t, {type})));
}

consteval auto type_add_const(info type) -> info {
Expand All @@ -1645,47 +1647,47 @@ consteval auto type_add_cv(info type) -> info {
}

consteval auto type_remove_reference(info type) -> info {
return dealias(substitute(^remove_reference_t, {type}));
return detail::__workaround_expand_compiler_builtins(dealias(substitute(^remove_reference_t, {type})));
}

consteval auto type_add_lvalue_reference(info type) -> info {
return dealias(substitute(^add_lvalue_reference_t, {type}));
return detail::__workaround_expand_compiler_builtins(dealias(substitute(^add_lvalue_reference_t, {type})));
}

consteval auto type_add_rvalue_reference(info type) -> info {
return dealias(substitute(^add_rvalue_reference_t, {type}));
return detail::__workaround_expand_compiler_builtins(dealias(substitute(^add_rvalue_reference_t, {type})));
}

consteval auto type_make_signed(info type) -> info {
return dealias(substitute(^make_signed_t, {type}));
return detail::__workaround_expand_compiler_builtins(dealias(substitute(^make_signed_t, {type})));
}

consteval auto type_make_unsigned(info type) -> info {
return dealias(substitute(^make_unsigned_t, {type}));
return detail::__workaround_expand_compiler_builtins(dealias(substitute(^make_unsigned_t, {type})));
}

consteval auto type_remove_extent(info type) -> info {
return dealias(substitute(^remove_extent_t, {type}));
return detail::__workaround_expand_compiler_builtins(dealias(substitute(^remove_extent_t, {type})));
}

consteval auto type_remove_all_extents(info type) -> info {
return dealias(substitute(^remove_all_extents_t, {type}));
return detail::__workaround_expand_compiler_builtins(dealias(substitute(^remove_all_extents_t, {type})));
}

consteval auto type_remove_pointer(info type) -> info {
return dealias(substitute(^remove_pointer_t, {type}));
return detail::__workaround_expand_compiler_builtins(dealias(substitute(^remove_pointer_t, {type})));
}

consteval auto type_add_pointer(info type) -> info {
return dealias(substitute(^add_pointer_t, {type}));
return detail::__workaround_expand_compiler_builtins(dealias(substitute(^add_pointer_t, {type})));
}

consteval auto type_remove_cvref(info type) -> info {
return dealias(substitute(^remove_cvref_t, {type}));
return detail::__workaround_expand_compiler_builtins(dealias(substitute(^remove_cvref_t, {type})));
}

consteval auto type_decay(info type) -> info {
return dealias(substitute(^decay_t, {type}));
return detail::__workaround_expand_compiler_builtins(dealias(substitute(^decay_t, {type})));
}

template <reflection_range R = span<info const>>
Expand All @@ -1699,7 +1701,7 @@ consteval auto type_common_reference(R &&type_args) -> info {
}

consteval auto type_underlying_type(info type) -> info {
return dealias(substitute(^underlying_type_t, {type}));
return detail::__workaround_expand_compiler_builtins(dealias(substitute(^underlying_type_t, {type})));
}

template <reflection_range R = span<info const>>
Expand Down Expand Up @@ -1882,6 +1884,13 @@ consteval auto accessible_subobjects_of(access_pair p) -> vector<info> {
return subobjects;
}

namespace detail {
template <class T> struct __wrap_workaround { using type = T; };
consteval auto __workaround_expand_compiler_builtins(info type) -> info {
return dealias(members_of(substitute(^__wrap_workaround, {type}))[0]);
}

} // namespace detail

#if __has_feature(parameter_reflection)

Expand Down