DRAFT.md: state the T-vs-I special member rule and the move-semantics divergence from P3019

Abierto Apto para principiantes
#194 1 comentario 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
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
76/100
Tipo de issue
Documentación
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
cpp

Línea de trabajo

Comienza en DRAFT.md, bajo Design, especialmente en “Generated structural subtyping”, y compara la redacción relevante sobre el constructor y la asignación en P3019R14. Documenta las restricciones relativas a T e I y, después, indica la divergencia en la semántica de movimiento y las condiciones del allocator; consulta #76, #193 y #148 para conocer el contexto de la redacción formal y de la implementación.

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

Descripción

Two gaps in DRAFT.md surfaced while looking at #187. Both concern how protocol's special member functions relate to those of std::polymorphic (P3019R14).

1. Constraints on T relative to I

DRAFT.md (Design, "Generated structural subtyping") says that if I has deleted special member functions, the corresponding members of protocol are not generated. It does not state the converse requirement on the stored type: a T must be copy constructible if I is, and move constructible if I is.

P3019 states this per constructor as a Constraints element (is_copy_constructible_v<U> on every constructor taking a U). protocol needs the generalised form, since it admits non-copyable interfaces:

Constraints: is_copy_constructible_v<T> is true if is_copy_constructible_v<I> is true; is_move_constructible_v<T> is true if is_move_constructible_v<I> is true.

This belongs in the Design section now and in the formal wording when #76 restores it. The implementation side is #193.

2. Divergence from P3019 on moves with equal allocators

P3019 [polymorphic.ctor]/8-9 and [polymorphic.assign]/6 permit the implementation to construct a new owned object "considering the owned object as an rvalue" even when the allocators compare equal; the drafting notes say this is to leave room for a small-buffer optimisation. That is only sound because every owned U is required to be copy constructible.

protocol cannot adopt that freedom: an immovable I (deleted move constructor) must still yield a movable protocol<I> for the default allocator and for any allocator where is_always_equal or propagate_on_container_move_assignment holds, and the only way to provide that is a guaranteed pointer steal when allocators compare equal. The paper should say so explicitly:

  • Move construction and move assignment of protocol never construct a new object of the stored type when the allocators compare equal (or the allocator propagates). They are noexcept in those cases.
  • Only the allocator-extended move constructor and move assignment with unequal, non-propagating allocators construct from the stored object as an rvalue, and those members are constrained on is_move_constructible_v<I>.

This also constrains #148: SBO would only be permissible for a protocol<I> where I is move constructible.

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.