-
Notifications
You must be signed in to change notification settings - Fork 3
Feat/unique ptr #41
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
Closed
Feat/unique ptr #41
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…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
…roper cleanup on construction failure
…r wrapper in Memory.h
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This UniquePtr implementation integrates with radiant's allocator system and provides standard smart pointer semantics with move-only ownership, customizable deleters, and automatic resource cleanup. The implementation uses EmptyOptimizedPair to achieve zero storage overhead for empty deleters (sizeof(UniquePtr) == sizeof(T*)). It supports type-safe conversions for inheritance hierarchies and integrates with AllocTraits for allocator-aware construction through two make_unique overloads: standard (new/delete) and allocator-aware.
The implementation follows radiant conventions, using Get() instead of get(), avoiding std:: dependencies, and integrating with the existing AllocTraits system. AllocatorDeleter provides automatic cleanup for allocator-constructed objects.
Comprehensive tests cover basic functionality, move semantics, custom deleters, type conversions, allocator integration, and edge cases including allocation failures.