Skip to content

Add pointer casts #5

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

Merged
merged 10 commits into from
Nov 13, 2021
Merged

Add pointer casts #5

merged 10 commits into from
Nov 13, 2021

Conversation

cschreib
Copy link
Owner

Main changes:

  • Added explicit casting constructors to observer_ptr
  • Added static_pointer_cast, const_pointer_cast, and dynamic_pointer_cast for all pointer types

Small changes and bugfixes:

  • Fixed explicit casting constructors for owner pointers leaking the control block when given a null pointer
  • Fixed explicit casting constructor for sealed pointers forcing a T* as input, rather preserving the user's pointer type throughout. In theory this could have broken enable_observer_from_this in some edge cases (T* not inheriting from enable_observer_from_this, but user-supplied V* does). However in practice, the raw pointer must come from a sealed pointer, and will therefore already have its control block setup correctly. So this has no observable consequence.

@codecov-commenter
Copy link

codecov-commenter commented Nov 13, 2021

Codecov Report

Merging #5 (6efeca0) into main (a1c175e) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##              main        #5   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            1         1           
  Lines          285       329   +44     
=========================================
+ Hits           285       329   +44     
Impacted Files Coverage Δ
include/oup/observable_unique_ptr.hpp 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a1c175e...6efeca0. Read the comment docs.

@cschreib cschreib merged commit fe5491b into main Nov 13, 2021
@cschreib cschreib deleted the pointer_casts branch November 13, 2021 17:43
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