X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Fcore%2Fvariant.h;h=6425fbfcbf7e4046d58105b445563f5e4d221acd;hp=b81bb506f300f8df2f215a63a427a7df38af7f7e;hb=3553d02ef9cf66ae5ff16dd0b129815f144857a1;hpb=d61601ce7f87044c8ddd1e097d8d8743f06e84b4 diff --git a/source/core/variant.h b/source/core/variant.h index b81bb50..6425fbf 100644 --- a/source/core/variant.h +++ b/source/core/variant.h @@ -9,6 +9,7 @@ Distributed under the LGPL #define MSP_CORE_VARIANT_H_ #include "except.h" +#include "meta.h" namespace Msp { @@ -33,21 +34,22 @@ private: public: Variant(): store(0) { } template - Variant(T v): store(new Store(v)) { } + Variant(const T &v): store(new Store::Type>(v)) { } ~Variant() { delete store; } template - Variant &operator=(T v) + Variant &operator=(const T &v) { delete store; - store=new Store(v); + store=new Store::Type>(v); return *this; } template - T value() const + T &value() const { - Store *s=dynamic_cast *>(store); + typedef typename RemoveConst::Type NCT; + Store *s=dynamic_cast *>(store); if(!s) throw InvalidState("Type mismatch"); return s->data; @@ -56,7 +58,7 @@ public: template bool check_type() const { - return dynamic_cast *>(store)!=0; + return dynamic_cast::Type> *>(store)!=0; } template