diff options
author | Jacques Lucke <jacques@blender.org> | 2021-02-25 19:17:45 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2021-02-25 19:17:45 +0300 |
commit | f908ff1ccdfb0133e1797877363f063b9daa696c (patch) | |
tree | 17eecaead648344d6af9542f320822f12580a534 /source/blender/blenlib | |
parent | 35df354e4aa4b1c848dfa0e1d80951e103caacea (diff) |
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.
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r-- | source/blender/blenlib/BLI_resource_collector.hh | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_resource_collector.hh b/source/blender/blenlib/BLI_resource_collector.hh index 20180f3b2c9..ecae9b8c682 100644 --- a/source/blender/blenlib/BLI_resource_collector.hh +++ b/source/blender/blenlib/BLI_resource_collector.hh @@ -108,6 +108,15 @@ class ResourceCollector : NonCopyable, NonMovable { } /** + * 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. */ |