Opened 11 years ago
Closed 9 years ago
#6164 closed Feature Requests (fixed)
Add a function to dynamic_bitset to test and set
Reported by: | Owned by: | acharles | |
---|---|---|---|
Milestone: | Boost 1.56.0 | Component: | dynamic_bitset |
Version: | Boost 1.48.0 | Severity: | Not Applicable |
Keywords: | Cc: |
Description
I often use an idiom:
if (!dynBitset.test(pos)) {
dynBitset.set(pos); do a once-only operation
It would be nice to have something like:
if (!dynBitset.test_set(pos)) {
do a once-only operation
Yes, it could be done by saving a temporary reference, but this form is compact and easy to understand.
Attachments (1)
Change History (5)
by , 11 years ago
Attachment: | msg1122.txt added |
---|
comment:1 by , 11 years ago
By the way, it might be worth noting that this isn't pretending to be an *atomic* test and set. There are specific machine instructions that do test and set atomically, used for synchronization. I don't think dynamic_bitset should consider being used as a synchronizer, so it shouldn't use the slower atomic operations.
comment:2 by , 9 years ago
Milestone: | To Be Determined → Boost 1.56.0 |
---|---|
Owner: | changed from | to
Severity: | Optimization → Not Applicable |
Status: | new → assigned |
comment:4 by , 9 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
a diff of current dynamic_bitset.hpp and my changed version