diff options
| author | ljfa-ag <ljfa-ag@web.de> | 2015-07-07 17:04:39 +0200 |
|---|---|---|
| committer | ljfa-ag <ljfa-ag@web.de> | 2015-07-07 17:04:39 +0200 |
| commit | 49bcfa77e1252fb9e4e55d6a5f97a420f6de8fc4 (patch) | |
| tree | e8ed279f93623fb35364ed2e8e21e516256f5681 /include | |
| parent | 4ea7019e8594254b77b72ea66e7700b2d8e6d2ef (diff) | |
| download | Project-Tick-49bcfa77e1252fb9e4e55d6a5f97a420f6de8fc4.tar.gz Project-Tick-49bcfa77e1252fb9e4e55d6a5f97a420f6de8fc4.zip | |
Create copy and clone functions for value and tag
Diffstat (limited to 'include')
| -rw-r--r-- | include/crtp_tag.h | 10 | ||||
| -rw-r--r-- | include/tag.h | 1 | ||||
| -rw-r--r-- | include/value.h | 5 |
3 files changed, 16 insertions, 0 deletions
diff --git a/include/crtp_tag.h b/include/crtp_tag.h index abd8b3b1ce..928759d6b8 100644 --- a/include/crtp_tag.h +++ b/include/crtp_tag.h @@ -37,6 +37,7 @@ namespace detail tag_type get_type() const noexcept override final; + std::unique_ptr<tag> clone() const& override final; std::unique_ptr<tag> move_clone() && override final; private: @@ -53,6 +54,15 @@ namespace detail return Sub::type; } + //TODO: Add copy constructors for tags that are missing it before this becomes useable + /*template<class Sub> + std::unique_ptr<tag> crtp_tag<Sub>::clone() const& + { + return std::unique_ptr<tag>( + new Sub(static_cast<const Sub&>(*this)) + ); + }*/ + template<class Sub> std::unique_ptr<tag> crtp_tag<Sub>::move_clone() && { diff --git a/include/tag.h b/include/tag.h index 6b037b9a32..da1d5098ad 100644 --- a/include/tag.h +++ b/include/tag.h @@ -54,6 +54,7 @@ public: ///Returns the type of the tag virtual tag_type get_type() const noexcept = 0; + virtual std::unique_ptr<tag> clone() const& = 0; virtual std::unique_ptr<tag> move_clone() && = 0; friend bool operator==(const tag& lhs, const tag& rhs); diff --git a/include/value.h b/include/value.h index 7d3dfc0e92..64e79efe9c 100644 --- a/include/value.h +++ b/include/value.h @@ -128,6 +128,11 @@ public: value& operator[](const std::string& key); value& operator[](const char* key); //need this overload because of conflict with built-in operator[] + /** + * @brief Creates a copy of the value + */ + value copy() const; + std::unique_ptr<tag>& get_ptr(); const std::unique_ptr<tag>& get_ptr() const; void set_ptr(std::unique_ptr<tag>&& t); |
