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

support gcc 4.8.1 #212

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
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
29 changes: 25 additions & 4 deletions src/json.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/*
__ _____ _____ _____
__| | __| | | | JSON for Modern C++
| | |__ | | | | | | version 2.0.0
Expand Down Expand Up @@ -4873,7 +4873,13 @@ class basic_json
// insert to array and return iterator
iterator result(this);
assert(m_value.array != nullptr);
result.m_it.array_iterator = m_value.array->insert(pos.m_it.array_iterator, cnt, val);
#if defined(__GNUC__) && __GNUC__ <= 4 && __GNUC_MINOR__ <= 8
auto insert_pos = std::distance(m_value.array->begin(), pos.m_it.array_iterator);
m_value.array->insert(pos.m_it.array_iterator, cnt, val);
result.m_it.array_iterator = m_value.array->begin() + insert_pos;
#else
result.m_it.array_iterator = m_value.array->insert(pos.m_it.array_iterator, cnt, val);
#endif
return result;
}
else
Expand Down Expand Up @@ -4939,10 +4945,19 @@ class basic_json
// insert to array and return iterator
iterator result(this);
assert(m_value.array != nullptr);
result.m_it.array_iterator = m_value.array->insert(

#if defined(__GNUC__) && __GNUC__ <= 4 && __GNUC_MINOR__ <= 8
auto insert_pos = std::distance(m_value.array->begin(), pos.m_it.array_iterator);
m_value.array->insert(pos.m_it.array_iterator,
first.m_it.array_iterator,
last.m_it.array_iterator);
result.m_it.array_iterator = m_value.array->begin() + insert_pos;
#else
result.m_it.array_iterator = m_value.array->insert(
pos.m_it.array_iterator,
first.m_it.array_iterator,
last.m_it.array_iterator);
#endif
return result;
}

Expand Down Expand Up @@ -4987,7 +5002,13 @@ class basic_json
// insert to array and return iterator
iterator result(this);
assert(m_value.array != nullptr);
result.m_it.array_iterator = m_value.array->insert(pos.m_it.array_iterator, ilist);
#if defined(__GNUC__) && __GNUC__ <= 4 && __GNUC_MINOR__ <= 8
auto insert_pos = std::distance(m_value.array->begin(), pos.m_it.array_iterator);
m_value.array->insert(pos.m_it.array_iterator, ilist);
result.m_it.array_iterator = m_value.array->begin() + insert_pos;
#else
result.m_it.array_iterator = m_value.array->insert(pos.m_it.array_iterator, ilist);
#endif
return result;
}

Expand Down
26 changes: 23 additions & 3 deletions src/json.hpp.re2c
Original file line number Diff line number Diff line change
Expand Up @@ -4873,7 +4873,13 @@ class basic_json
// insert to array and return iterator
iterator result(this);
assert(m_value.array != nullptr);
result.m_it.array_iterator = m_value.array->insert(pos.m_it.array_iterator, cnt, val);
#if defined(__GNUC__) && __GNUC__ <= 4 && __GNUC_MINOR__ <= 8
auto insert_pos = std::distance(m_value.array->begin(), pos.m_it.array_iterator);
m_value.array->insert(pos.m_it.array_iterator, cnt, val);
result.m_it.array_iterator = m_value.array->begin() + insert_pos;
#else
result.m_it.array_iterator = m_value.array->insert(pos.m_it.array_iterator, cnt, val);
#endif
return result;
}
else
Expand Down Expand Up @@ -4939,10 +4945,18 @@ class basic_json
// insert to array and return iterator
iterator result(this);
assert(m_value.array != nullptr);
result.m_it.array_iterator = m_value.array->insert(
#if defined(__GNUC__) && __GNUC__ <= 4 && __GNUC_MINOR__ <= 8
auto insert_pos = std::distance(m_value.array->begin(), pos.m_it.array_iterator);
m_value.array->insert(pos.m_it.array_iterator,
first.m_it.array_iterator,
last.m_it.array_iterator);
result.m_it.array_iterator = m_value.array->begin() + insert_pos;
#else
result.m_it.array_iterator = m_value.array->insert(
pos.m_it.array_iterator,
first.m_it.array_iterator,
last.m_it.array_iterator);
#endif
return result;
}

Expand Down Expand Up @@ -4987,7 +5001,13 @@ class basic_json
// insert to array and return iterator
iterator result(this);
assert(m_value.array != nullptr);
result.m_it.array_iterator = m_value.array->insert(pos.m_it.array_iterator, ilist);
#if defined(__GNUC__) && __GNUC__ <= 4 && __GNUC_MINOR__ <= 8
auto insert_pos = std::distance(m_value.array->begin(), pos.m_it.array_iterator);
m_value.array->insert(pos.m_it.array_iterator, ilist);
result.m_it.array_iterator = m_value.array->begin() + insert_pos;
#else
result.m_it.array_iterator = m_value.array->insert(pos.m_it.array_iterator, ilist);
#endif
return result;
}

Expand Down