Comparison between two protocol objects

Abierto
#440 2 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
25/100
Tipo de issue
Nueva funcionalidad
Claridad
Necesita aclaración
Estado de actividad
Activo
Stack tecnológico
cpp

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

#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.

Lenguaje dominante
C++
Estrellas
12
Forks
4
Merge medio
1 d 11 h
PR fusionados (30 d)
15

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de jbcoe/cc-protocol

Todos los issues de jbcoe/cc-protocol

Issues similares

Más issues de C++

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.