Skip to content

Conversation

@snej
Copy link
Contributor

@snej snej commented Nov 22, 2025

  • destroy() method releases the reference, equivalent to = nullptr
    which is otherwise disallowed. This is for cases where a non-null
    reference needs to be released in e.g. a close() method, but it's
    understood that it can't be accessed again. This allows it to be
    typed as Ref<>.
  • isValid() returns false if the Ref has been destroyed.
  • operator bool is disallowed for Ref<>, because it's conceptually
    not nullable, so testing it is usually a sign that you're doing
    unnecessary checks. If you really need to check, use isValid().

Also converted some Retaineds into Refs in the Fleece codebase, and fixed a template method in ValueSlot that didn't work with Ref.

Also fixed some new clang printf warnings.

snej added 3 commits November 21, 2025 12:01
Clang started noticing some format-string type mismatches
- `destroy()` method releases the reference, equivalent to `= nullptr`
  which is otherwise disallowed. This is for cases where a non-null
  reference needs to be released in e.g. a `close()` method, but it's
  understood that it can't be accessed again. This allows it to be
  typed as `Ref<>`.
- `isValid()` returns false if the Ref has been destroyed.
- `operator bool` is disallowed for Ref<>, because it's conceptually
  not nullable, so testing it is usually a sign that you're doing
  unnecessary checks. If you really need to check, use isValid().
Converted some `Retained` into `Ref`s.
Fixed a template method in ValueSlot that didn't work with `Ref`.
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.

2 participants