Comparison between two protocol objects

Đang mở
#440 2 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
25/100
Loại issue
Tính năng
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Sôi nổi
Công nghệ
cpp
Lĩnh vực
backend-api-design

Hướng nghiên cứu

The issue names no files or tests. Start by reading #439 and #208, then trace the protocol and protocol_view comparison design described here; done means the open semantic, type-identity, mismatch, valueless, conversion, and scope questions have a decided specification.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

#439 forwards member comparisons with an operand of another type and rejects any comparison on an interface I with an operand of type I. The idiomatic declaration is therefore free to be given a meaning:

struct I {
  bool operator==(const I&) const = default;
  auto operator<=>(const I&) const = default;
};
protocol<I> p(A{}), q(B{});
p == q;

Open questions:

  1. Meaning. Does const I& stand for the conforming type itself? Conformance would then mean C has operator==(const C&) const, and protocol<I> would get operator==(const protocol&) const. Should that apply only to defaulted comparisons, or to user-declared ones as well?
  2. Type identity. The thunk must know that both operands hold the same C before it casts. typeid needs RTTI. The vtable address is cheap but not reliably unique across shared libraries.
  3. Mismatched types. == can return false. <=> could return partial_ordering::unordered (which rules out strong_ordering on the interface), order by type_index (an unspecified order), or throw as Boost.TypeErasure does. std::polymorphic omits comparison for this reason.
  4. Valueless operands. See #208.
  5. protocol_view. Does it compare the referenced objects or the pointers? Should mixed protocol/protocol_view comparison be allowed?
  6. Conversions between interfaces. What does a comparison that names the conforming type do when a protocol converts to another interface?
  7. Scope. Does "own type" stop at comparisons, or extend to members such as void merge(const I&) and I clone() const?

An alternative is a library opt-in (a tag base or trait) in place of rewriting const I&. That works against the design's premise that the interface struct is the whole specification.

Ngôn ngữ chính
C++
Star
12
Fork
4
Merge trung bình
1 ngày 11 giờ
Pull request đã merge (30 ngày)
15

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của jbcoe/cc-protocol

Tất cả issue của jbcoe/cc-protocol

Issue tương tự

Thêm issue về C++

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.