This is an archive of the discontinued LLVM Phabricator instance.

[libc] add features to bitset
ClosedPublic

Authored by michaelrj on Oct 27 2022, 1:31 PM.

Details

Summary

This patch adds the flip, set_range, and operator== functions to bitset.
These will be used in scanf.

Diff Detail

Event Timeline

michaelrj created this revision.Oct 27 2022, 1:31 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptOct 27 2022, 1:31 PM
michaelrj requested review of this revision.Oct 27 2022, 1:31 PM
sivachandra accepted this revision.Oct 27 2022, 1:47 PM

Please add unit-tests for the new methods.

libc/src/__support/CPP/bitset.h
40

This method is not in std::bitset so we should not include it here. You can define a helper function in the other patch with the same functionality.

This revision is now accepted and ready to land.Oct 27 2022, 1:47 PM
michaelrj added inline comments.Oct 27 2022, 3:04 PM
libc/src/__support/CPP/bitset.h
40

defining this function outside of the bitset class is less efficient because the internal Data array is private. I could implement it as a loop of calls to set but that would be masking one bit at a time.

sivachandra added inline comments.Oct 27 2022, 3:40 PM
libc/src/__support/CPP/bitset.h
40

Sigh, OK! Nevermind then.

michaelrj updated this revision to Diff 471320.Oct 27 2022, 4:22 PM

add unit tests and a "reset" function to support those tests. Also squash some bugs found with the tests.

This revision was automatically updated to reflect the committed changes.