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:
2021-02-25 17:17:45 +01:00
parent 35df354e4a
commit f908ff1ccd

View File

@@ -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.