From 4efbf602230c39b311655a726903478977f53b79 Mon Sep 17 00:00:00 2001 From: ljfa-ag Date: Wed, 8 Jul 2015 18:24:02 +0200 Subject: Make assign method public --- include/crtp_tag.h | 11 ++++++----- include/tag.h | 14 ++++++-------- 2 files changed, 12 insertions(+), 13 deletions(-) (limited to 'include') 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 clone() const& override final; std::unique_ptr 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 @@ -71,15 +72,15 @@ namespace detail } template - bool crtp_tag::equals(const tag& rhs) const + tag& crtp_tag::assign(tag&& rhs) { - return static_cast(*this) == static_cast(rhs); + return *this = dynamic_cast(rhs); } template - tag& crtp_tag::assign(tag&& rhs) + bool crtp_tag::equals(const tag& rhs) const { - return *this = dynamic_cast(rhs); + return static_cast(*this) == static_cast(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 move_clone() && = 0; std::unique_ptr 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; }; } -- cgit 0.0.5-2-1-g0f52