Skip to content

Fix: Apply the "safe bool" idiom to ConfigureQueueStatus #590

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

vinay-deshmukh
Copy link
Collaborator

@vinay-deshmukh vinay-deshmukh commented Jan 29, 2025

Issue number of the reported bug or feature request: #350

Describe your changes

Apply safe bool idiom

Testing performed
Describe the testing you have performed to ensure that the bug has been addressed, or that the new feature works as planned.

Assuming CI has existing tests for the component

Additional context
Add any other context about your contribution here.

@vinay-deshmukh vinay-deshmukh requested a review from a team as a code owner January 29, 2025 02:19
@vinay-deshmukh vinay-deshmukh force-pushed the vinay-issue-350 branch 2 times, most recently from 34c58c2 to 6f6d01c Compare January 29, 2025 02:50
@vinay-deshmukh vinay-deshmukh changed the title Apply the "safe bool" idiom to ConfigureQueueStatus Fix: Apply the "safe bool" idiom to ConfigureQueueStatus Jan 29, 2025
@chrisbeard
Copy link
Contributor

I believe the test failures are not related. @hallfox want to take a quick look?

// Use of an `UnspecifiedBool` to prevent implicit conversions to
// integral values, and comparisons between different classes which
// have boolean operators.
typedef bsls::UnspecifiedBool<ConfigureQueueStatus>::BoolType BoolType;
Copy link
Collaborator

Choose a reason for hiding this comment

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

This type definition should be private

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I pretty much copied bmqa_closequestatus.h's typedef from:

public:
// TRAITS
BSLMF_NESTED_TRAIT_DECLARATION(CloseQueueStatus, bslma::UsesBslmaAllocator)
// TYPES
// Use of an `UnspecifiedBool` to prevent implicit conversions to
// integral values, and comparisons between different classes which
// have boolean operators.
typedef bsls::UnspecifiedBool<CloseQueueStatus>::BoolType BoolType;

  1. Should that be made private as well?

  2. If the typedef becomes private, would the public BoolType operator() const even be usable to clients?

Copy link
Collaborator

@hallfox hallfox Apr 16, 2025

Choose a reason for hiding this comment

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

  1. If possible yes, but we can do that in a separate PR
  2. It still works, the only thing that changes is that you can't refer to BoolType directly. Which is fine, because we're only using this to get statements like if (configureQueueStatus) to work. Conversions still work despite the BoolType typename being private.

@vinay-deshmukh
Copy link
Collaborator Author

@hallfox Can you take a look at this PR when you get a chance? Thanks!

@vinay-deshmukh vinay-deshmukh force-pushed the vinay-issue-350 branch 2 times, most recently from 9b6821e to 7f425c3 Compare April 17, 2025 00:38
Signed-off-by: Vinay Deshmukh <32487576+vinay-deshmukh@users.noreply.github.com>
Copy link

@bmq-oss-ci bmq-oss-ci bot left a comment

Choose a reason for hiding this comment

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

Build 2579 of commit 4e341bd has completed with FAILURE

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.

3 participants