diff options
| author | ljfa-ag <ljfa-ag@web.de> | 2015-07-08 18:24:02 +0200 |
|---|---|---|
| committer | ljfa-ag <ljfa-ag@web.de> | 2015-07-08 18:24:02 +0200 |
| commit | 4efbf602230c39b311655a726903478977f53b79 (patch) | |
| tree | 671c89768ce07e65005cfa330f2faca3e759700c | |
| parent | 0b0b7c343fd1d40a10d7c756237b8e86207d8b97 (diff) | |
| download | Project-Tick-4efbf602230c39b311655a726903478977f53b79.tar.gz Project-Tick-4efbf602230c39b311655a726903478977f53b79.zip | |
Make assign method public
| -rw-r--r-- | include/crtp_tag.h | 11 | ||||
| -rw-r--r-- | include/tag.h | 14 |
2 files changed, 12 insertions, 13 deletions
diff --git a/include/crtp_tag.h b/include/crtp_tag.h index df1272a3d3..8611038ffa 100644 --- a/include/crtp_tag.h +++ b/include/crtp_tag.h @@ -40,9 +40,10 @@ namespace detail std::unique_ptr<tag> clone() const& override final; std::unique_ptr<tag> move_clone() && override final; + tag& assign(tag&& rhs) override final; + private: bool equals(const tag& rhs) const override final; - tag& assign(tag&& rhs) override final; }; template<class Sub> @@ -71,15 +72,15 @@ namespace detail } template<class Sub> - bool crtp_tag<Sub>::equals(const tag& rhs) const + tag& crtp_tag<Sub>::assign(tag&& rhs) { - return static_cast<const Sub&>(*this) == static_cast<const Sub&>(rhs); + return *this = dynamic_cast<Sub&&>(rhs); } template<class Sub> - tag& crtp_tag<Sub>::assign(tag&& rhs) + bool crtp_tag<Sub>::equals(const tag& rhs) const { - return *this = dynamic_cast<Sub&&>(rhs); + return static_cast<const Sub&>(*this) == static_cast<const Sub&>(rhs); } } diff --git a/include/tag.h b/include/tag.h index c38c9a5117..b972a16da6 100644 --- a/include/tag.h +++ b/include/tag.h @@ -58,6 +58,12 @@ public: virtual std::unique_ptr<tag> move_clone() && = 0; std::unique_ptr<tag> clone() &&; + /** + * @brief Move-assigns the given tag if the class is the same + * @throw std::bad_cast if @c rhs is not the same type as @c *this + */ + virtual tag& assign(tag&& rhs) = 0; + friend bool operator==(const tag& lhs, const tag& rhs); friend bool operator!=(const tag& lhs, const tag& rhs); @@ -67,14 +73,6 @@ private: * @param rhs an instance of the same class as @c *this */ virtual bool equals(const tag& rhs) const = 0; - - /** - * @brief Move-assigns the given tag if the class is the same - * @throw std::bad_cast if @c rhs is not the same type as @c *this - */ - virtual tag& assign(tag&& rhs) = 0; - - friend class value; }; } |
