+
+inline void Variant::clear()
+{
+ if(funcs)
+ funcs->destroy(storage);
+ funcs = nullptr;
+}
+
+template<typename T>
+inline void Variant::assign(const T &v)
+{
+ clear();
+ funcs = get_functions<typename std::remove_cv<T>::type>();
+ create(storage, v);
+}
+
+inline void Variant::copy_from(const Variant &v)
+{
+ clear();
+ if((funcs = v.funcs))
+ funcs->clone(storage, v.storage);
+}
+
+template<typename T>
+inline T &Variant::get()
+{
+ if(!has_type<T>())
+ throw type_mismatch(typeid(T), (funcs ? funcs->get_type() : typeid(void)));
+
+ if(sizeof(T)<=INTERNAL_SIZE)
+ return *reinterpret_cast<T *>(storage);
+ else
+ return **reinterpret_cast<T **>(storage);
+}
+
+inline bool Variant::type_equals(const Functions *funcs1, const Functions *funcs2)
+{
+ if(!funcs1 || !funcs2)
+ return false;
+ else if(funcs1==funcs2)
+ return true;
+ else
+ return funcs1->get_type()==funcs2->get_type();
+}
+
+template<typename T>
+inline const Variant::Functions *Variant::get_functions()
+{
+ static Functions funcs =
+ {
+ &get_type<T>,
+ &compare<T>,
+ &clone<T>,
+ &destroy<T>
+ };
+ return &funcs;
+}
+