X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcore%2Fvariant.h;h=4a0c89cf1a9a4b22661d28e62ba192a06004aabd;hb=ff0d3252cad08280b9c320b3fea5a11c80406c23;hp=e00885c94210ef720c3d48c42769d99a7d3182f8;hpb=d16185720fa344263367dbd50c61bfc8183d99a4;p=libs%2Fcore.git diff --git a/source/core/variant.h b/source/core/variant.h index e00885c..4a0c89c 100644 --- a/source/core/variant.h +++ b/source/core/variant.h @@ -61,14 +61,28 @@ public: return *this; } +private: template - T &value() const + Store::Type> *get_typed_store() const { typedef typename RemoveConst::Type NCT; Store *s = dynamic_cast *>(store); if(!s) throw type_mismatch(typeid(T), (store ? store->type_id() : typeid(void))); - return s->data; + return s; + } + +public: + template + T &value() + { + return get_typed_store()->data; + } + + template + const T &value() const + { + return get_typed_store()->data; } template