From 1ce4f17facba4dfe62cf52c83b4d59e51b659c31 Mon Sep 17 00:00:00 2001 From: ljfa-ag Date: Sun, 12 Jul 2015 18:19:38 +0200 Subject: Implement tag_list --- include/tag_list.h | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/tag_list.h b/include/tag_list.h index d0b80ebb01..fe5a6818fa 100644 --- a/include/tag_list.h +++ b/include/tag_list.h @@ -21,6 +21,8 @@ #define TAG_LIST_H_INCLUDED #include "crtp_tag.h" +#include "value.h" +#include #include namespace nbt @@ -98,7 +100,7 @@ public: ///Returns the number of tags in the list size_t size() const; - ///Erases all tags from the list + ///Erases all tags from the list. Preserves the content type. void clear(); //Iterators @@ -117,6 +119,16 @@ private: tag_type el_type_; }; +template +void tag_list::emplace_back(Args&&... args) +{ + if(el_type_ == tag_type::Null) //set content type if undetermined + el_type_ = T::type; + else if(el_type_ != T::type) + throw std::bad_cast(); + tags.emplace_back(T(std::forward(args)...)); +} + } #endif // TAG_LIST_H_INCLUDED -- cgit 0.0.5-2-1-g0f52