Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix python wheel compilation #233

Merged
merged 1 commit into from
Jun 27, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 31 additions & 24 deletions brion/detail/json.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* clang-format off */

/*
__ _____ _____ _____
__| | __| | | | JSON for Modern C++
Expand Down Expand Up @@ -125,7 +127,7 @@ using json = basic_json<>;
"unsupported Clang version - see https://github.com/nlohmann/json#supported-compilers"
#endif
#elif defined(__GNUC__) && !(defined(__ICC) || defined(__INTEL_COMPILER))
#if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 40900
#if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 40800
#error \
"unsupported GCC version - see https://github.com/nlohmann/json#supported-compilers"
#endif
Expand Down Expand Up @@ -10983,6 +10985,23 @@ class basic_json
return object.release();
}

/// helper for insertion of an iterator (supports GCC 4.8+)
template<typename... Args>
iterator insert_iterator(const_iterator pos, Args&& ... args)
{
iterator result(this);
assert(m_value.array != nullptr);

auto insert_pos = std::distance(m_value.array->begin(), pos.m_it.array_iterator);
m_value.array->insert(pos.m_it.array_iterator, std::forward<Args>(args)...);
result.m_it.array_iterator = m_value.array->begin() + insert_pos;

// For GCC 4.9+ only, this could become:
// result.m_it.array_iterator = m_value.array->insert(pos.m_it.array_iterator, cnt, val);

return result;
}

////////////////////////
// JSON value storage //
////////////////////////
Expand Down Expand Up @@ -15203,10 +15222,7 @@ class basic_json
}

// insert to array and return iterator
iterator result(this);
result.m_it.array_iterator =
m_value.array->insert(pos.m_it.array_iterator, val);
return result;
return insert_iterator(pos, val);
}

JSON_THROW(type_error::create(309, "cannot use insert() with " +
Expand Down Expand Up @@ -15259,10 +15275,7 @@ class basic_json
}

// insert to array and return iterator
iterator result(this);
result.m_it.array_iterator =
m_value.array->insert(pos.m_it.array_iterator, cnt, val);
return result;
return insert_iterator(pos, cnt, val);
}

JSON_THROW(type_error::create(309, "cannot use insert() with " +
Expand Down Expand Up @@ -15329,12 +15342,10 @@ class basic_json
}

// insert to array and return iterator
iterator result(this);
result.m_it.array_iterator =
m_value.array->insert(pos.m_it.array_iterator,
first.m_it.array_iterator,
last.m_it.array_iterator);
return result;
return insert_iterator(
pos,
first.m_it.array_iterator,
last.m_it.array_iterator);
}

/*!
Expand Down Expand Up @@ -15378,11 +15389,7 @@ class basic_json
}

// insert to array and return iterator
iterator result(this);
result.m_it.array_iterator =
m_value.array->insert(pos.m_it.array_iterator, ilist.begin(),
ilist.end());
return result;
return insert_iterator(pos, ilist.begin(), ilist.end());
}

/*!
Expand Down Expand Up @@ -17933,15 +17940,15 @@ class basic_json

@since version 3.0.0
*/
void merge_patch(const basic_json& patch)
void merge_patch(const basic_json& jspatch)
{
if (patch.is_object())
if (jspatch.is_object())
{
if (not is_object())
{
*this = object();
}
for (auto it = patch.begin(); it != patch.end(); ++it)
for (auto it = jspatch.begin(); it != jspatch.end(); ++it)
{
if (it.value().is_null())
{
Expand All @@ -17955,7 +17962,7 @@ class basic_json
}
else
{
*this = patch;
*this = jspatch;
}
}

Expand Down