diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2024-01-26 17:56:52 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2024-01-26 17:56:52 +0000 |
commit | 14d82ff67eab5d94b69fb38ea6a0bc634674245c (patch) | |
tree | 2f66f17b95b23b0b4f053b1aa0f00d65297ab24a /lib | |
parent | Remove the static font cache (diff) | |
download | ilt-14d82ff67eab5d94b69fb38ea6a0bc634674245c.tar.bz2 ilt-14d82ff67eab5d94b69fb38ea6a0bc634674245c.tar.xz ilt-14d82ff67eab5d94b69fb38ea6a0bc634674245c.zip |
Remove the generic cache completely
Diffstat (limited to 'lib')
-rw-r--r-- | lib/cache.cpp | 1 | ||||
-rw-r--r-- | lib/cache.h | 39 |
2 files changed, 0 insertions, 40 deletions
diff --git a/lib/cache.cpp b/lib/cache.cpp deleted file mode 100644 index 05b26b0..0000000 --- a/lib/cache.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "cache.h" diff --git a/lib/cache.h b/lib/cache.h deleted file mode 100644 index f5fd227..0000000 --- a/lib/cache.h +++ /dev/null @@ -1,39 +0,0 @@ -#pragma once - -#include "special_members.h" -#include <functional> -#include <map> -#include <memory> -#include <tuple> - -template<typename Obj, typename... KeyParts> class Cache { -public: - using Ptr = std::shared_ptr<Obj>; - using Key = std::tuple<KeyParts...>; - - Cache() = default; - virtual ~Cache() = default; - DEFAULT_MOVE(Cache); - NO_COPY(Cache); - - [[nodiscard]] Ptr - get(const KeyParts &... keyparts) - { - auto key = std::tie(keyparts...); - if (auto e = cached.find(key); e != cached.end()) { - return e->second; - } - return cached.emplace(key, construct(keyparts...)).first->second; - } - - [[nodiscard]] virtual Ptr - construct(const KeyParts &... keyparts) const - { - return std::make_shared<Obj>(keyparts...); - } - -private: - std::map<Key, Ptr, std::less<>> cached; -}; - -// IWYU pragma: no_forward_declare Cache |