The Wayback Machine - https://web.archive.org/web/20211016190017/https://github.com/godotengine/godot/pull/51656
Skip to content
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

The PagedAllocator can now allocate objects with non empty constructors. #51656

Merged

Conversation

@AndreaCatania
Copy link
Member

@AndreaCatania AndreaCatania commented Aug 14, 2021

Add the possibility to initialize the classes allocated with the PagedAllocator

It uses the (const T &&... p_args) forward reference, to avoid copying the memory in case the passed argument is an rvalue, or pass a reference in case it's an lvalue.

This is an example:

PagedAllocator<btShapeBox> box_allocator;
btShapeBox* box = box_allocator.alloc( /* Half extension */btVector3(1.0, 1.0, 1.0) );

You can still use the PagedAllocator as usual, initializing the class using the empty constructor:

PagedAllocator<Transform> transform_allocator;
Transform* tansform = transform_allocator.alloc();
…dAllocator

It uses the (`const T &&... p_args`) forward reference, to avoid copying the
memory in case it's an rvalue, or pass a reference in case it's an lvalue.

This is an example:
```c++
PagedAllocator<btShapeBox> box_allocator;
btShapeBox* box = box_allocator.alloc( btVector3(1.0, 1.0, 1.0) );
```
@AndreaCatania AndreaCatania added this to the 4.0 milestone Aug 14, 2021
@AndreaCatania AndreaCatania requested a review from reduz Aug 14, 2021
@AndreaCatania AndreaCatania requested a review from as a code owner Aug 14, 2021
reduz
reduz approved these changes Aug 14, 2021
@akien-mga akien-mga merged commit 087ec7b into godotengine:master Aug 14, 2021
11 checks passed
@akien-mga
Copy link
Member

@akien-mga akien-mga commented Aug 14, 2021

Thanks!

@AndreaCatania AndreaCatania deleted the paged-allocator-initializer branch Aug 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment