Skip to content

Commit 0ec1923

Browse files
committed
Add construction of json_arrayt / json_objectt from range
Another attempt to resolve the abiguity error when compiling with g++5
1 parent d818939 commit 0ec1923

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/util/json.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Author: Daniel Kroening, [email protected]
1616
#include <string>
1717

1818
#include "irep.h"
19+
#include "range.h"
1920

2021
class json_objectt;
2122
class json_arrayt;
@@ -175,6 +176,12 @@ class json_arrayt:public jsont
175176
{
176177
}
177178

179+
template <typename iteratort>
180+
explicit json_arrayt(ranget<iteratort> &&range)
181+
: json_arrayt(kindt::J_ARRAY, arrayt{range.begin(), range.end()})
182+
{
183+
}
184+
178185
void resize(std::size_t size)
179186
{
180187
array.resize(size);
@@ -304,6 +311,12 @@ class json_objectt:public jsont
304311
{
305312
}
306313

314+
template <typename iteratort>
315+
explicit json_objectt(ranget<iteratort> &&range)
316+
: json_objectt(kindt::J_OBJECT, objectt{range.begin(), range.end()})
317+
{
318+
}
319+
307320
jsont &operator[](const std::string &key)
308321
{
309322
return object[key];

0 commit comments

Comments
 (0)