Skip to content

add priority_queue wrapper - #56

Open
Anshumancanrock wants to merge 4 commits into
rustfoundation:mainfrom
Anshumancanrock:stdcpp-priority-queue
Open

Anshumancanrock wants to merge 4 commits into
rustfoundation:mainfrom
Anshumancanrock:stdcpp-priority-queue

Conversation

@Anshumancanrock

@Anshumancanrock Anshumancanrock commented Oct 15, 2026 •

Copy link
Copy Markdown

Add priority queue wrappers using the overload! macro

Closes #47

  1. Write Rust wrappers for that C++ type, for 3-5 different overloaded method names:
    • Create a new file named after your type in overloading-macros/cpp-overload-test/src/stdcpp
    • Wrap constructors first, writing tests to make sure the correct constructor is called
    • Explain any potential compatibility issues in a Limitations doc section
    • Explain usability issues in an Ergonomics doc section
    • Check that you have implemented all the overloads for each method name, or documented why you can't
    • Push your changes and wait for a review
  2. Add a separate example with some failing overloads
    • Create a new file named after your type in overloading-macros/cpp-overload-test/examples
    • Wrap accessor/modifier methods
    • Explain how they fail in an Incompatibilities doc section
    • Explain how the overload failures could be resolved in a Workarounds doc section
    • Optional: If there's a C++ feature with no equivalent in Rust, explain that in an Inexpressible Overloads doc section
    • Push your changes and wait for a review
  3. Update the overload macro compatibility table Markdown doc
    • If you haven't checked some kinds of overloads, put a ?in those squares
    • Push your changes and wait for a review

AI disclosure: Claude helped me with syntax, conceptual solution and debug build failures.

@teor2345
teor2345 self-requested a review October 15, 2026 21:04
@teor2345
teor2345 marked this pull request as draft October 15, 2026 21:04
@teor2345

This comment was marked as resolved.

@Anshumancanrock

This comment was marked as resolved.

@teor2345

This comment was marked as resolved.

@Anshumancanrock

Copy link
Copy Markdown
Author

I can see your agent committed 6 large commits in 1 minute. Some of them rewrote lines that had nothing to do with this PR. So there's maybe a bit more going on here?

Yes, 6 commits were made using claude after clearing my previous commits as they were messed up a bit. Going forward, I’ll make commits by hand to prevent this from happening again.

That's useful, but it's not enough for our policy. Generating large amounts of code or documentation using AI is banned, because it is often poor quality, verbose, and takes a lot of reviewer time.

edit: I'm sorry if this wasn't clear, I've updated the policies to say this directly.

Thanks for mentioning this clearly. I’m well aware of AI policies and have used AI to understand some concepts, resolve errors, and review code. During reviews, AI made auto edits to parts of the code that were unrelated to the PR which i later reverted.

How did you make the AI text generator (Claude) ignore the AGENTS file STOP instructions?

It should have stopped immediately, and refused to write source code comments and soundness-sensitive (unsafe) code.

AGENTS file instuctions were not ignored initially. But when i was debugging test failures, ai auto fixed some code to resolve errors.

@teor2345

This comment was marked as resolved.

@teor2345

This comment was marked as resolved.

@Anshumancanrock
Anshumancanrock marked this pull request as ready for review October 16, 2026 15:54
@Anshumancanrock

This comment was marked as resolved.

@teor2345 teor2345 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please make these changes and then comment so I know to do another review.

Comment thread cpp-overloads-in-rust.md
Comment thread cpp-overload-test/examples/stdcpp-priority-queue.rs
}

overload! {
impl StdPriorityQueue {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I see 10 non-allocator constructors, but there are only 5 implemented here.
Please do this step again:

Check that you have implemented all the overloads for each method name, or documented why you can't

https://en.cppreference.com/cpp/container/priority_queue/priority_queue


overload! {
impl StdPriorityQueue {
pub fn emplace(&mut self) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Emplace can forward to any item constructor overloads. Is there anything different about using emplace that could make constructor overloads incompatible?

For example, does the extra self argument matter?
Or is there an element type and constructor that could conflict with the other emplace overloads?

Please document the item types where this could be a problem, or document why it isn't a problem for any item types.

@Anshumancanrock

Copy link
Copy Markdown
Author

Hi @teor2345, I've implemented the missing non-allocator constructors and documented emplace overload limitations. Please take a look when you get a chance.

@Anshumancanrock

Copy link
Copy Markdown
Author

Hi @teor2345 I’ve updated the docs to explain the emplace limitations more clearly, including which item types can cause overload clashes, why they happen, and why this wrapper is fine.

Could you please take a look when you get a chance?

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.

priority_queue

2 participants