X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcore%2Fvariant.h;h=af204f2233f3c7759665a0f6b729bd52459d4326;hb=4ad05c650c55e3edccea887d15b26f41cdf60fb6;hp=443befb481620b4242e178a4b377192179af1adc;hpb=41363aed34382386f915f17c1a961750b4fdcb14;p=libs%2Fcore.git diff --git a/source/core/variant.h b/source/core/variant.h index 443befb..af204f2 100644 --- a/source/core/variant.h +++ b/source/core/variant.h @@ -12,7 +12,7 @@ class type_mismatch: public std::runtime_error { public: type_mismatch(const std::type_info &, const std::type_info &); - virtual ~type_mismatch() throw() = default; + ~type_mismatch() throw() override = default; }; @@ -36,10 +36,10 @@ private: Store(const T &d): data(d) { } - virtual const std::type_info &type_id() const { return typeid(T); } - virtual StoreBase *clone() const { return new Store(data); } - virtual bool type_equals(const StoreBase &s) const { return dynamic_cast *>(&s); } - virtual bool value_equals(const StoreBase &s) const { return _value_equals(s); } + const std::type_info &type_id() const override { return typeid(T); } + StoreBase *clone() const override { return new Store(data); } + bool type_equals(const StoreBase &s) const override { return dynamic_cast *>(&s); } + bool value_equals(const StoreBase &s) const override { return _value_equals(s); } template typename std::enable_if::value, bool>::type _value_equals(const StoreBase &s) const @@ -69,6 +69,9 @@ public: Variant &operator=(const Variant &v) { + if(&v==this) + return *this; + delete store; store = (v.store ? v.store->clone() : nullptr); return *this;