Repository navigation
Support wide character streams in rational output - #58
Open
trestoncuzzort wants to merge 1 commit into
Open
trestoncuzzort wants to merge 1 commit into
trestoncuzzort wants to merge 1 commit into
Conversation
Use the destination stream's character type and traits for the output operator and its temporary buffer. Wide streams otherwise select the Boolean conversion and print 1 for a nonzero rational. Extend the existing output tests with wide fractions and formatting checks, and update the documented operator signature. Assisted-by: OpenAI Codex
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #40.
Writing
boost::rational<int>(1, 3)to a wide stream currently prints1. The output operator only acceptsstd::ostream, so a wide stream falls back to the rational's Boolean conversion.Template the output operator and its temporary buffer on the destination stream's character type and traits. This reuses the existing formatting algorithm for wide streams. Update the documented signature and extend the existing tests with wide fractions, zero/nonzero values under
boolalpha, width/fill, signs, internal alignment and hexadecimal prefixes.Validation on Linux:
rational_testpass.git diff --checkpasses. Native Windows and 32-bit builds were not run.OpenAI Codex assisted with investigation, implementation and tests.