diff options
| author | ljfa-ag <ljfa-ag@web.de> | 2015-07-12 18:19:38 +0200 |
|---|---|---|
| committer | ljfa-ag <ljfa-ag@web.de> | 2015-07-12 18:19:38 +0200 |
| commit | 1ce4f17facba4dfe62cf52c83b4d59e51b659c31 (patch) | |
| tree | 87ef369de95c589b0e3b5bfc22a502ede83edf07 /include | |
| parent | a6e071d35535c6097458d12ca268bd73c582dcfc (diff) | |
| download | Project-Tick-1ce4f17facba4dfe62cf52c83b4d59e51b659c31.tar.gz Project-Tick-1ce4f17facba4dfe62cf52c83b4d59e51b659c31.zip | |
Implement tag_list
Diffstat (limited to 'include')
| -rw-r--r-- | include/tag_list.h | 14 |
1 files changed, 13 insertions, 1 deletions
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 <typeinfo> #include <vector> 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<class T, class... Args> +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>(args)...)); +} + } #endif // TAG_LIST_H_INCLUDED |
