Browse Source

Replaced nullptr_t with void* in object's variant

master
Jessica James 5 years ago
parent
commit
21ac7ba4eb
  1. 5
      src/common/object.cpp
  2. 5
      src/include/object.hpp

5
src/common/object.cpp

@ -41,8 +41,7 @@ object::object(const std::string_view& in_str)
/** Accessors */
bool object::null() const {
// There's something funny about variants holding nullptr_t
return std::holds_alternative<nullptr_t>(m_value);
return std::holds_alternative<null_variant_t>(m_value);
}
size_t object::size() const {
@ -95,7 +94,7 @@ object& object::operator[](const std::string& in_key) {
}
static thread_local object s_null_object;
s_null_object.m_value.emplace<nullptr_t>();
s_null_object.m_value.emplace<null_variant_t>();
return s_null_object;
}

5
src/include/object.hpp

@ -405,7 +405,7 @@ public:
return std::visit([this](auto&& value) -> size_t {
using T = typename std::decay<decltype(value)>::type;
if constexpr (std::is_same<T, nullptr_t>::value) {
if constexpr (std::is_same<T, null_variant_t>::value) {
return 0;
}
else if constexpr (std::is_same<T, array_t>::value) {
@ -431,7 +431,8 @@ public:
}
private:
std::variant<nullptr_t, bool, intmax_t, long double, std::string, array_t, map_t> m_value;
using null_variant_t = void*;
std::variant<null_variant_t, bool, intmax_t, long double, std::string, array_t, map_t> m_value;
}; // object
} // namespace jessilib

Loading…
Cancel
Save