We propose the addition of two class templates, protocol<T, A> and
protocol_view<T>, to the C++ Standard Library. Both classes support
structural-subtyping, protocol is owning, protocol_view is non-owning.
See DRAFT.md for more details on design.
This repository contains both the ISO C++ proposal to add these new library
types and a reference implementation, protocol.hh, built on C++26 reflection
(P2996). It requires a compiler with reflection support, such as a GCC trunk
snapshot with -freflection.
The paper P4148R2 (derived from DRAFT.md) was presented to the C++ Standard Library Incubator working group in Brno on June 11th 2026. The authors have been encouraged to continue work.
For build instructions, testing and contributing guidelines, see CONTRIBUTING.md.
Press . or visit [https://github.dev/jbcoe/cc-protocol] to open the project in
an instant, cloud-based, development environment. We have defined a
devcontainer that will automatically install
the dependencies required to build and test the project.