diff options
Diffstat (limited to 'src/value.cc')
-rw-r--r-- | src/value.cc | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/value.cc b/src/value.cc index a39eada2..e7f726ce 100644 --- a/src/value.cc +++ b/src/value.cc @@ -104,6 +104,26 @@ value_t::operator bool() const return false; } +void value_t::set_type(type_t new_type) +{ + assert(new_type >= VOID && new_type <= POINTER); + if (new_type == VOID) { +#if BOOST_VERSION >= 103700 + storage.reset(); +#else + storage = intrusive_ptr<storage_t>(); +#endif + assert(is_null()); + } else { + if (! storage || storage->refc > 1) + storage = new storage_t; + else + storage->data = false; // destruct all other types + storage->type = new_type; + assert(is_type(new_type)); + } +} + bool value_t::to_boolean() const { if (is_boolean()) { |