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
14 changes: 7 additions & 7 deletions xyz/detail/protocol_wrappers.hh
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ enum class const_policy {
propagate,
// `protocol_view<I>`: every wrapper is const-qualified regardless of `I`
// (shallow const, as for `std::span`).
all_const,
constify,
// `protocol_view<const I>`: only the const member functions of `I`.
const_only,
only_const,
};

// Returns `true` if `member` if forwarded under `ConstPolicy`.
Expand All @@ -56,11 +56,11 @@ consteval bool is_forwarded_member_function(
// `protocol<T>` propagates const through forwarded member function calls
// so supports const and non-const qualified member functions.
return true;
case const_policy::const_only:
case const_policy::only_const:
// `protocol_view<const T>` forwards only const-qualified member
// functions.
return is_const(member);
case const_policy::all_const:
case const_policy::constify:
// `protocol_view<T>` is a view type: overload resolution through
// a const and non-const access path must yield the same result.
// A const-qualified member function is only given a forwarding wrapper if
Expand Down Expand Up @@ -88,8 +88,8 @@ consteval void reject_conversion_functions_of_mixed_constness(
std::meta::info first = {};
for (std::meta::info member : members) {
if (!is_conversion_function(member) ||
!is_forwarded_member_function<const_policy::all_const>(member,
members)) {
!is_forwarded_member_function<const_policy::constify>(member,
members)) {
continue;
}
if (first == std::meta::info{}) {
Expand Down Expand Up @@ -156,7 +156,7 @@ template <std::meta::info InterfaceType, typename ProtocolType, typename Vtable,
consteval std::meta::info generate_member_bases_wrapper() {
std::span<const std::meta::info> members =
protocol_interface_functions_of<InterfaceType>;
if (ConstPolicy == const_policy::all_const) {
if (ConstPolicy == const_policy::constify) {
reject_conversion_functions_of_mixed_constness(members);
}
std::vector<std::meta::info> member_base_types;
Expand Down
4 changes: 2 additions & 2 deletions xyz/protocol.hh
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ template <detail::is_valid_view_interface T>
class protocol_view
: public detail::protocol_wrappers_t<T, protocol_view<T>,
detail::vtable_t<T>,
detail::const_policy::all_const> {
detail::const_policy::constify> {
public:
// The default constructor is deleted as a default constructed
// `protocol_view` would be empty.
Expand Down Expand Up @@ -669,7 +669,7 @@ template <detail::is_valid_interface T>
class protocol_view<const T>
: public detail::protocol_wrappers_t<T, protocol_view<const T>,
detail::vtable_t<T>,
detail::const_policy::const_only> {
detail::const_policy::only_const> {
public:
// The default constructor is deleted as a default constructed
// `protocol_view` would be empty.
Expand Down
2 changes: 1 addition & 1 deletion xyz/tests/protocol_operator_tests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ consteval bool view_wrappers_reject() {
try {
(void)xyz::detail::generate_member_bases_wrapper<
^^Interface, protocol_view<Interface>, xyz::detail::vtable_t<Interface>,
xyz::detail::const_policy::all_const>();
xyz::detail::const_policy::constify>();
} catch (const std::runtime_error&) {
return true;
}
Expand Down
Loading