Skip to content

Commit

Permalink
feat: nullptr for null
Browse files Browse the repository at this point in the history
  • Loading branch information
MistEO committed Jan 25, 2024
1 parent 6deb2e7 commit 7079f57
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions include/common/object.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include <cstddef>
#include <initializer_list>
#include <map>
#include <memory>
Expand Down Expand Up @@ -59,6 +60,7 @@ class basic_value

basic_value(const char_t* str);
basic_value(string_t str);
basic_value(std::nullptr_t);

basic_value(basic_array<string_t> arr);
basic_value(basic_object<string_t> obj);
Expand Down Expand Up @@ -569,6 +571,10 @@ template <typename string_t>
inline basic_value<string_t>::basic_value(string_t str) : _type(value_type::string), _raw_data(std::move(str))
{}

template <typename string_t>
inline basic_value<string_t>::basic_value(std::nullptr_t) : _type(value_type::null)
{}

template <typename string_t>
inline basic_value<string_t>::basic_value(basic_array<string_t> arr)
: _type(value_type::array), _raw_data(std::make_unique<basic_array<string_t>>(std::move(arr)))
Expand Down
1 change: 1 addition & 0 deletions test/serializing_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ bool serializing()

root["hello"] = "meojson";
root["Pi"] = 3.1416;
root["null"] = nullptr;

root["obj"] = {
{ "obj_key1", "Hi" },
Expand Down

0 comments on commit 7079f57

Please sign in to comment.