Skip to content

Conversation

Copilot
Copy link

@Copilot Copilot AI commented Oct 13, 2025

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 in include/boost/http_proto/method.hpp to include a new @par Enumeration Constants section that guarantees:

  • The first constant (method::unknown) starts at 0
  • Each subsequent constant is incremented by exactly one
  • This property makes the constants suitable for use as indexes into a compact array

Example Use Case

With this documented guarantee, users can now confidently write code like:

const char* method_names[34] = { /* ... */ };
method m = method::get;
const char* name = method_names[static_cast<int>(m)];  // Safe to use as array index

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

This section details on the original issue you should resolve

<issue_title>http_proto::method enumeration additional invariants</issue_title>
<issue_description>The documentation comment for the http_proto::method enumeration should state an additional guarantee: That the first constant starts at 0 (zero), and each subsequent constant is incremented by one, making the constants suitable for use as indexes into a compact array. Any fixes for this issue should limit changes to ONLY the documentation comment for http_proto::method.</issue_description>

Comments on the Issue (you are @copilot in this section)

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.

Document that method enum constants start at 0 and increment by 1,
making them suitable for use as indexes into a compact array.

Co-authored-by: vinniefalco <[email protected]>
@Copilot Copilot AI changed the title [WIP] Update documentation for http_proto::method enumeration Document method enum indexing invariant Oct 13, 2025
@Copilot Copilot AI requested a review from vinniefalco October 13, 2025 18:24
Copilot finished work on behalf of vinniefalco October 13, 2025 18:24
Each item corresponds to a particular method string
used in HTTP request messages.
@par Enumeration Constants
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename this section to simply "Values"

Copy link

codecov bot commented Oct 13, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.48%. Comparing base (1a8a81c) to head (4d2c852).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff            @@
##           develop     #180   +/-   ##
========================================
  Coverage    92.48%   92.48%           
========================================
  Files           71       71           
  Lines         4854     4854           
========================================
  Hits          4489     4489           
  Misses         365      365           

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1a8a81c...4d2c852. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

http_proto::method enumeration additional invariants

2 participants