File tree 3 files changed +11
-4
lines changed 3 files changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -738,6 +738,7 @@ class JSON_API ValueConstIterator : public ValueIteratorBase {
738
738
typedef ValueConstIterator SelfType;
739
739
740
740
ValueConstIterator ();
741
+ ValueConstIterator (ValueIterator const & other);
741
742
742
743
private:
743
744
/* ! \internal Use by Value to create an iterator.
@@ -787,7 +788,7 @@ class JSON_API ValueIterator : public ValueIteratorBase {
787
788
typedef ValueIterator SelfType;
788
789
789
790
ValueIterator ();
790
- ValueIterator (const ValueConstIterator& other);
791
+ explicit ValueIterator (const ValueConstIterator& other);
791
792
ValueIterator (const ValueIterator& other);
792
793
793
794
private:
Original file line number Diff line number Diff line change @@ -129,6 +129,9 @@ ValueConstIterator::ValueConstIterator(
129
129
const Value::ObjectValues::iterator& current)
130
130
: ValueIteratorBase(current) {}
131
131
132
+ ValueConstIterator::ValueConstIterator (ValueIterator const & other)
133
+ : ValueIteratorBase(other) {}
134
+
132
135
ValueConstIterator& ValueConstIterator::
133
136
operator =(const ValueIteratorBase& other) {
134
137
copy (other);
@@ -149,7 +152,9 @@ ValueIterator::ValueIterator(const Value::ObjectValues::iterator& current)
149
152
: ValueIteratorBase(current) {}
150
153
151
154
ValueIterator::ValueIterator (const ValueConstIterator& other)
152
- : ValueIteratorBase(other) {}
155
+ : ValueIteratorBase(other) {
156
+ throwRuntimeError (" ConstIterator to Iterator should never be allowed." );
157
+ }
153
158
154
159
ValueIterator::ValueIterator (const ValueIterator& other)
155
160
: ValueIteratorBase(other) {}
Original file line number Diff line number Diff line change 10
10
#include < limits>
11
11
#include < sstream>
12
12
#include < string>
13
- #include < iostream>
14
13
#include < iomanip>
15
14
16
15
// Make numeric limits more convenient to talk about.
@@ -2436,7 +2435,9 @@ JSONTEST_FIXTURE(IteratorTest, indexes) {
2436
2435
2437
2436
JSONTEST_FIXTURE (IteratorTest, const ) {
2438
2437
Json::Value const v;
2439
- Json::Value::iterator it = v.begin (); // This *should not* compile, but does.
2438
+ JSONTEST_ASSERT_THROWS (
2439
+ Json::Value::iterator it (v.begin ()) // Compile, but throw.
2440
+ );
2440
2441
2441
2442
Json::Value value;
2442
2443
You can’t perform that action at this time.
0 commit comments