mirror of
https://github.com/ETLCPP/etl.git
synced 2026-04-30 19:09:10 +08:00
Updated unique_ptr-with-pool
This commit is contained in:
parent
bebf98800c
commit
da1ded3d77
@ -27,7 +27,10 @@ struct S
|
||||
|
||||
int main()
|
||||
{
|
||||
// The pool to allocate from.
|
||||
etl::pool<S, 10> pool;
|
||||
|
||||
// The deleter called by unique_ptr.
|
||||
auto pool_deleter = [&pool](auto ptr)
|
||||
{
|
||||
std::cout << "Releasing S(" << ptr->a << ", " << ptr->b << ") back to pool." << std::endl;
|
||||
@ -40,6 +43,7 @@ int main()
|
||||
std::cout << "Created S(" << us1->a << ", " << us1->b << ") from pool." << std::endl;
|
||||
|
||||
{
|
||||
// Unique with local scope.
|
||||
Unique us2(pool.create(3, 4), pool_deleter);
|
||||
std::cout << "Created S(" << us2->a << ", " << us2->b << ") from pool." << std::endl;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user