Skip to content

Fix Shared bool conversion#27

Merged
dprokoptsev merged 1 commit into
hudson-trading:masterfrom
jeet-dekivadia:fix-shared-bool-validity
Jun 10, 2026
Merged

Fix Shared bool conversion#27
dprokoptsev merged 1 commit into
hudson-trading:masterfrom
jeet-dekivadia:fix-shared-bool-validity

Conversation

@jeet-dekivadia

Copy link
Copy Markdown
Contributor

Fixes #26.

Shared::operator bool() currently returns !state_, which makes a default-constructed empty Shared truthy and a constructed Shared falsey. That is the opposite of the existing get() semantics and the usual pointer-like contract used by operator*/operator->.

This changes the bool conversion to follow the underlying IntrusivePtr validity and adds coverage in the existing shared adapter test for both constructed and empty handles.

Validation:

  • git diff --check
  • cmake -S . -B /tmp/corral-shared-bool-build -DSKIP_EXAMPLES=ON -DCORRAL_BOOST=''
  • standalone AppleClang 16 compile/link of test/basic_test.cc + test/adapter_test.cc, then /tmp/corral-adapter-bool-build/corral_adapter_test shared -> all 16 assertions passed

@dprokoptsev dprokoptsev merged commit f409beb into hudson-trading:master Jun 10, 2026
12 checks passed
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.

Shared::operator bool returns the opposite of handle validity

2 participants