Document method enum indexing invariant #180
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
This PR adds documentation to the
http_proto::method
enumeration to explicitly state an important invariant: that the enumeration constants begin at 0 and increment by 1, making them suitable for use as indexes into compact arrays.Changes
Updated the documentation comment for
enum class method
ininclude/boost/http_proto/method.hpp
to include a new@par Enumeration Constants
section that guarantees:method::unknown
) starts at 0Example Use Case
With this documented guarantee, users can now confidently write code like:
Verification
The enumeration values were verified to follow this invariant:
method::unknown = 0
method::delete_ = 1
method::get = 2
method::unlink = 33
All 34 constants are sequential with no gaps.
Impact
This is a documentation-only change with no modifications to code or enum values. The invariant has always been true for this enum; this PR simply documents the guarantee for library users.
Fixes #[issue_number]
Original prompt
Fixes #179
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.