Skip to content

feat: EBO‑optimized UniquePtr<T, Deleter> #39

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

Closed
wants to merge 11 commits into from

Conversation

brodheadw
Copy link

Closes #1: implement std‑like UniquePtr with EBO, converting moves, nullptr‑assign, etc.

brodheadw added 11 commits May 8, 2025 15:45
…n requirement to Development Setup section of CONTRIBUTING.md
…d version requirement to Development Setup section of CONTRIBUTING.md"

This reverts commit 2c4c34f.
…n requirement to Development Setup section of CONTRIBUTING.md
- Create radiant/UniquePtr.h with the class template declaration,
  default and pointer‐taking constructors, destructor and move‐ops.
- Add placeholder comments for the missing member functions.
Change UniquePtr to inherit from an empty DefaultDelete deleter so sizeof(UniquePtr<T>) == sizeof(T*)

Fix ctor to initialize base deleter, not mistakenly pass pointer

Remove stored function-pointer field, rely on empty-base optimization

Update UniquePtrDefault alias to use the new DefaultDelete

Add test/test_UniquePtr.cpp covering basic lifetime, release/reset, move, swap and custom deleter size guarantee

test: revise tests for EBO-optimized DefaultDelete (drop old alias, move D and its count to namespace scope, simplify static_assert, update CustomDeleter test)
…sive tests

Introduce DefaultDelete<T> as an empty deleter type to enable empty-base-optimization

Refactor UniquePtr<T, Deleter> to inherit from Deleter, removing extra storage and ensuring sizeof(UniquePtr) == sizeof(T*)

Add move-ctor, move-assign, release, reset, swap, and nullptr conversion APIs

Provide ADL-friendly swap overload

Update alias UniquePtrDefault<T> to use default deleter

Add test/test_UniquePtr.cpp with GoogleTest suite covering basic lifetime, sizeof check, release/reset, move semantics, swap semantics, and custom deleter
…d of std traits

add converting constructor to DefaultDelete to allow DefaultDelete<Base> from DefaultDelete<Derived>

remove <type_traits> dependency and replace std::is_convertible_v with rad::IsConv

keep existing move and converting-move overloads unchanged; tests continue to pass
Copy link

CLA Assistant Lite bot:
Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


You can retrigger this bot by commenting recheck in this Pull Request

@brodheadw brodheadw closed this May 13, 2025
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.

UniquePtr implementation
1 participant