BLI: simplify adding an arbitrary value to a resource container
With this is becomes easily possible to store a lambda in a resource collector so that it will be freed when the resource collector is freed.
This commit is contained in:
@@ -107,6 +107,15 @@ class ResourceCollector : NonCopyable, NonMovable {
|
||||
m_resources.append(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct an object with the same value in the ResourceCollector and return a reference to the
|
||||
* new value.
|
||||
*/
|
||||
template<typename T> T &add_value(T &&value, const char *name)
|
||||
{
|
||||
return this->construct<T>(name, std::forward<T>(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a reference to a linear allocator that is owned by the ResourcesCollector. Memory
|
||||
* allocated through this allocator will be freed when the collector is destructed.
|
||||
|
||||
Reference in New Issue
Block a user