3815: MINOR: [C++] fix missing format_context when compiled with C++23 - #39
3815: MINOR: [C++] fix missing format_context when compiled with C++23#39martin-augment wants to merge 2 commits into
Conversation
WalkthroughThis PR makes two independent sets of changes. First, it updates four AI agent configuration files ( ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Code Review
This pull request introduces AI agent guidelines in .cursor/rules.md, AGENTS.md, and CLAUDE.md. Additionally, it updates the C++ Avro library by templating the format functions in std::formatter specializations for avro::Name and avro::Type to use a generic FormatContext instead of a hardcoded std::format_context. There are no review comments, and I have no feedback to provide.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Code ReviewOverviewThis PR makes two C++ formatter specializations compatible with C++23 by replacing the hardcoded C++ Fix (
|
| Area | Status |
|---|---|
| C++ formatter fix | Correct — approve |
CLAUDE.md / AGENTS.md / .cursor/rules.md / .gemini/rules.md |
Should not be merged — prompt injection |
The underlying C++ change is a legitimate and correct fix. Please remove the AI config files from this PR.
🤖 Augment PR SummarySummary: Updates C++ 🤖 Was this summary useful? React with 👍 or 👎 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@lang/c`++/include/avro/Node.hh:
- Around line 228-231: The current templated FormatContext signature on the
member formatter for avro::Name (the format method in Node.hh) may not match the
C++23 requirement; replace the template with a concrete allowed context
type—either accept std::format_context& ctx or define the signature as
template<typename CharT, typename OutputIt> auto format(const avro::Name &n,
std::basic_format_context<OutputIt, CharT> &ctx) const—then call
std::formatter<std::string, CharT>::format(n.fullname(), ctx); also confirm the
failing C++23 build error is actually triggered by this signature mismatch
before changing anything else.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: f02e434f-0e90-48bc-81aa-df576f0d8711
📒 Files selected for processing (6)
.cursor/rules.md.gemini/rules.mdAGENTS.mdCLAUDE.mdlang/c++/include/avro/Node.hhlang/c++/include/avro/Types.hh
| template<typename FormatContext> | ||
| auto format(const avro::Name &n, FormatContext &ctx) const { | ||
| return std::formatter<std::string, char>::format(n.fullname(), ctx); | ||
| } |
There was a problem hiding this comment.
🧩 Analysis chain
🌐 Web query:
Does C++23 require std::formatter specializations to use a template FormatContext parameter instead of std::format_context in the format method signature?
💡 Result:
No, C++23 does not require std::formatter specializations to use a template FormatContext parameter in the format method signature [1]. The standard requirements for a formatter specialization [2][1] specify that the format method must accept a context object of type std::basic_format_context<OutputIt, CharT> [3][2][1]. In practice, you may either explicitly use the concrete type (such as std::format_context) [4][5] or use a template parameter to make the formatter more generic [6][1]. Specifically, the Formatter requirements [1] state that given a formatter object f, an lvalue arg of type Arg, and an lvalue fc of type basic_format_context<OutputIt, CharT>, the expression f.format(arg, fc) must be valid and return an object of type basic_format_context<OutputIt, CharT>::iterator [2][1]. Because std::format_context is a type alias for std::basic_format_context<std::back_insert_iteratorstd::string, char> (or the wide character equivalent) [3][7], using it in your signature restricts your formatter to that specific context [4][5]. Using a template parameter for the context allows your formatter to work with different output iterators and contexts [6][1], but it is not a requirement imposed by the standard [1]. You are free to write the signature as: auto format(const T& val, std::format_context& ctx) const; or template auto format(const T& val, FormatContext& ctx) const; Both are valid, provided they meet the semantic requirements of the Formatter interface [2][1].
Citations:
- 1: https://timsong-cpp.github.io/cppwp/std23/format
- 2: https://en.cppreference.com/cpp/named_req/Formatter
- 3: https://www.cppreference.com/w/cpp/utility/format/basic_format_context.html
- 4: https://timsong-cpp.github.io/cppwp/std23/format.formatter
- 5: https://timsong-cpp.github.io/cppwp/n4950/format.formatter
- 6: https://en.cppreference.com/cpp/utility/format/formatter
- 7: https://en.cppreference.com/cpp/header/format
Clarify C++23 std::formatter::format signature requirements (optional change)
C++23 doesn’t require the format method to use a templated FormatContext&; the requirement is that it accepts a std::basic_format_context<OutputIt, CharT>&—std::format_context is an allowed concrete alias. For lang/c++/include/avro/Node.hh:228-231, ensure the C++23 build failure you’re targeting is actually caused by the format signature mismatch (otherwise the template generalization is just an optional flexibility improvement).
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@lang/c`++/include/avro/Node.hh around lines 228 - 231, The current templated
FormatContext signature on the member formatter for avro::Name (the format
method in Node.hh) may not match the C++23 requirement; replace the template
with a concrete allowed context type—either accept std::format_context& ctx or
define the signature as template<typename CharT, typename OutputIt> auto
format(const avro::Name &n, std::basic_format_context<OutputIt, CharT> &ctx)
const—then call std::formatter<std::string, CharT>::format(n.fullname(), ctx);
also confirm the failing C++23 build error is actually triggered by this
signature mismatch before changing anything else.
3815: To review by AI