summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/NBT/CompoundTag.hpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/NBT/CompoundTag.hpp b/src/NBT/CompoundTag.hpp
index 28efc41..39fa25d 100644
--- a/src/NBT/CompoundTag.hpp
+++ b/src/NBT/CompoundTag.hpp
@@ -54,13 +54,15 @@ public:
return Type::Compound;
}
- template<typename T>
- std::shared_ptr<const T> get(const std::string &key) const {
- return std::dynamic_pointer_cast<const T>(at(key));
+ template<typename T> std::shared_ptr<const T> get(const std::string &key) const {
+ auto it = find(key);
+ if (it == end())
+ return std::shared_ptr<const T>();
+
+ return std::dynamic_pointer_cast<const T>(it->second);
}
- template<typename T, typename... Args>
- std::shared_ptr<const T> get(const std::string &key, const Args &...args) const {
+ template<typename T, typename... Args> std::shared_ptr<const T> get(const std::string &key, const Args &...args) const {
std::shared_ptr<const CompoundTag> tag = get<CompoundTag>(key);
if (!tag)
return std::shared_ptr<const T>();