X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Fcore%2Fvariant.h;h=443befb481620b4242e178a4b377192179af1adc;hp=05a8139c679783000f9e56d65ae6674029931d49;hb=41363aed34382386f915f17c1a961750b4fdcb14;hpb=122846f0881673770d88eff7d925ecf25c01b62e diff --git a/source/core/variant.h b/source/core/variant.h index 05a8139..443befb 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 &); - ~type_mismatch() throw() { } + virtual ~type_mismatch() throw() = default; }; @@ -39,24 +39,24 @@ private: 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); } + virtual bool value_equals(const StoreBase &s) const { return _value_equals(s); } template - typename std::enable_if::value, bool>::type value_equals_(const StoreBase &s) const + typename std::enable_if::value, bool>::type _value_equals(const StoreBase &s) const { const Store *t = dynamic_cast *>(&s); return (t && t->data==data); } template - typename std::enable_if::value, bool>::type value_equals_(const StoreBase &) const + typename std::enable_if::value, bool>::type _value_equals(const StoreBase &) const { return false; } }; - StoreBase *store = 0; + StoreBase *store = nullptr; public: - Variant() { } + Variant() = default; template Variant(const T &v): store(new Store::type>(v)) { } - Variant(const Variant &v): store(v.store ? v.store->clone() : 0) { } + Variant(const Variant &v): store(v.store ? v.store->clone() : nullptr) { } ~Variant() { delete store; } template @@ -70,7 +70,7 @@ public: Variant &operator=(const Variant &v) { delete store; - store = (v.store ? v.store->clone() : 0); + store = (v.store ? v.store->clone() : nullptr); return *this; } @@ -101,7 +101,7 @@ public: template bool check_type() const { - return dynamic_cast::type> *>(store)!=0; + return dynamic_cast::type> *>(store); } bool check_same_type(const Variant &v) const