summaryrefslogtreecommitdiff
path: root/lib/cache.h
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2024-01-27 21:47:41 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2024-01-27 21:47:41 +0000
commite0ac130808d9bed5443115ee91e9cccda713ae3c (patch)
treedad2b2cbe2bc8bf5560f4859880549472f808671 /lib/cache.h
parentRemove the static texture cache (diff)
parentRender text in N draw calls (diff)
downloadilt-e0ac130808d9bed5443115ee91e9cccda713ae3c.tar.bz2
ilt-e0ac130808d9bed5443115ee91e9cccda713ae3c.tar.xz
ilt-e0ac130808d9bed5443115ee91e9cccda713ae3c.zip
Merge branch 'text2'
Diffstat (limited to 'lib/cache.h')
-rw-r--r--lib/cache.h39
1 files changed, 0 insertions, 39 deletions
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