inline void basic_val<T>::copy(self_type const& o) { if (type() == o.type()) { switch (o.type()) { case type_info::object: o_ = o.o_; break; case type_info::array: a_ = o.a_; break; case type_info::string: s_ = o.s_; break; case type_info::int_: i_ = o.i_; break; case type_info::double_: d_ = o.d_; break; case type_info::bool_: b_ = o.b_; break; default: break; } return; } free(); switch (type_ = o.type()) { case type_info::object: new (&o_) object(o.o_); break; case type_info::array: new (&a_) array(o.a_); break; case type_info::string: new (&s_) string(o.s_); break; case type_info::int_: i_ = o.i_; break; case type_info::double_: d_ = o.d_; break; case type_info::bool_: b_ = o.b_; break; default: break; } }
inline bool basic_val<T>::operator==(self_type const& v) const { if (type() != v.type()) return false; switch (type()) { case type_info::object: return o_ == v.o_; case type_info::array: return a_ == v.a_; case type_info::string: return s_ == v.s_; case type_info::int_: return i_ == v.i_; case type_info::double_: return d_ == v.d_; case type_info::bool_: return b_ == v.b_; default: break; } return true; }