3 This file is part of libmspcore
4 Copyright © 2006-2007 Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
8 #ifndef MSP_CORE_VARIANT_H_
9 #define MSP_CORE_VARIANT_H_
20 virtual ~StoreBase() { }
24 struct Store: public StoreBase
28 Store(T d): data(d) { }
34 Variant(): store(0) { }
36 Variant(T v): store(new Store<T>(v)) { }
37 ~Variant() { delete store; }
40 Variant &operator=(T v)
43 store=new Store<T>(v);
50 Store<T> *s=dynamic_cast<Store<T> *>(store);
52 throw InvalidState("Type mismatch");
57 bool check_type() const
59 return dynamic_cast<Store<T> *>(store)!=0;
64 { return value<T>(); }