fixed [] operator; added README

This commit is contained in:
Niels committed 2015-02-18 22:28:56 +01:00
1 parent ca981270a0
commit afd02eee44
4 files changed
+621 -2

No files matched your search

+18
View File
@@ -760,6 +760,15 @@ class basic_json
/// access specified element
inline reference operator[](const typename object_t::key_type& key)
{
// implicitly convert null to object
if (m_type == value_t::null)
{
m_type = value_t::object;
Allocator<object_t> alloc;
m_value.object = alloc.allocate(1);
alloc.construct(m_value.object);
}
// at only works for objects
if (m_type != value_t::object)
{
@@ -785,6 +794,15 @@ class basic_json
template<typename T, size_t n>
inline reference operator[](const T (&key)[n])
{
// implicitly convert null to object
if (m_type == value_t::null)
{
m_type = value_t::object;
Allocator<object_t> alloc;
m_value.object = alloc.allocate(1);
alloc.construct(m_value.object);
}
// at only works for objects
if (m_type != value_t::object)
{
+18
View File
@@ -760,6 +760,15 @@ class basic_json
/// access specified element
inline reference operator[](const typename object_t::key_type& key)
{
// implicitly convert null to object
if (m_type == value_t::null)
{
m_type = value_t::object;
Allocator<object_t> alloc;
m_value.object = alloc.allocate(1);
alloc.construct(m_value.object);
}
// at only works for objects
if (m_type != value_t::object)
{
@@ -785,6 +794,15 @@ class basic_json
template<typename T, size_t n>
inline reference operator[](const T (&key)[n])
{
// implicitly convert null to object
if (m_type == value_t::null)
{
m_type = value_t::object;
Allocator<object_t> alloc;
m_value.object = alloc.allocate(1);
alloc.construct(m_value.object);
}
// at only works for objects
if (m_type != value_t::object)
{