summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorljfa-ag <ljfa-ag@web.de>2015-07-09 18:00:42 +0200
committerljfa-ag <ljfa-ag@web.de>2015-07-09 18:00:42 +0200
commitea71042f79738bcdc08fe3bfa0a2f9cd1c0c03ac (patch)
treed6d9a00d078fc3a5f94a2caca86b6c34d83943f6
parent4efbf602230c39b311655a726903478977f53b79 (diff)
downloadProject-Tick-ea71042f79738bcdc08fe3bfa0a2f9cd1c0c03ac.tar.gz
Project-Tick-ea71042f79738bcdc08fe3bfa0a2f9cd1c0c03ac.zip
Change signature of put to take value
-rw-r--r--include/tag_compound.h4
-rw-r--r--src/tag_compound.cpp6
-rw-r--r--test/nbttest.cpp4
3 files changed, 7 insertions, 7 deletions
diff --git a/include/tag_compound.h b/include/tag_compound.h
index 2b02ec5ba3..80be2f609e 100644
--- a/include/tag_compound.h
+++ b/include/tag_compound.h
@@ -70,7 +70,7 @@ public:
* @return a pair of the iterator to the value and a bool indicating
* whether the key did not exist
*/
- std::pair<iterator, bool> put(const std::string& key, std::unique_ptr<tag>&& t);
+ std::pair<iterator, bool> put(const std::string& key, value&& val);
/**
* @brief Constructs and assigns or inserts a tag into the compound
@@ -116,7 +116,7 @@ private:
template<class T, class... Args>
std::pair<tag_compound::iterator, bool> tag_compound::emplace(const std::string& key, Args&&... args)
{
- return put(key, std::unique_ptr<tag>(new T(std::forward<Args>(args)...)));
+ return put(key, value(T(std::forward<Args>(args)...)));
}
}
diff --git a/src/tag_compound.cpp b/src/tag_compound.cpp
index b0a36c30f4..4c6c03264e 100644
--- a/src/tag_compound.cpp
+++ b/src/tag_compound.cpp
@@ -43,17 +43,17 @@ value& tag_compound::operator[](const std::string& key)
return tags[key];
}
-std::pair<tag_compound::iterator, bool> tag_compound::put(const std::string& key, std::unique_ptr<tag>&& t)
+std::pair<tag_compound::iterator, bool> tag_compound::put(const std::string& key, value&& val)
{
auto it = tags.find(key);
if(it != tags.end())
{
- it->second.set_ptr(std::move(t));
+ it->second = std::move(val);
return {it, false};
}
else
{
- return tags.emplace(key, value(std::move(t)));
+ return tags.emplace(key, std::move(val));
}
}
diff --git a/test/nbttest.cpp b/test/nbttest.cpp
index 5470b047ab..42f8bd25f4 100644
--- a/test/nbttest.cpp
+++ b/test/nbttest.cpp
@@ -142,8 +142,8 @@ void test_tag_compound()
comp.clear();
ASSERT(comp == tag_compound{});
- ASSERT(comp.put("abc", std::unique_ptr<tag>(new tag_double(6.0))).second == true);
- ASSERT(comp.put("abc", std::unique_ptr<tag>(new tag_long(-28))).second == false);
+ ASSERT(comp.put("abc", value(tag_double(6.0))).second == true);
+ ASSERT(comp.put("abc", value(tag_long(-28))).second == false);
ASSERT(comp.emplace<tag_string>("def", "ghi").second == true);
ASSERT(comp.emplace<tag_byte>("def", 4).second == false);
ASSERT((comp == tag_compound{{"abc", tag_long(-28)}, {"def", tag_byte(4)}}));