In value.h, ValueConstIterator can convert to ValueIterator, I think that is a bug. the correct way is ValueIterator can convert to ValueConstIterator.
typedef ValueConstIterator SelfType;
ValueConstIterator();
+ ValueConstIterator(ValueIterator const& other);
private:
/*! \internal Use by Value to create an iterator.
typedef ValueIterator SelfType;
ValueIterator();
- ValueIterator(const ValueConstIterator& other);
+ explicit ValueIterator(const ValueConstIterator& other);
ValueIterator(const ValueIterator& other);
private:
const Value::ObjectValues::iterator& current)
: ValueIteratorBase(current) {}
+ValueConstIterator::ValueConstIterator(ValueIterator const& other)
+ : ValueIteratorBase(other) {}
+
ValueConstIterator& ValueConstIterator::
operator=(const ValueIteratorBase& other) {
copy(other);
: ValueIteratorBase(current) {}
ValueIterator::ValueIterator(const ValueConstIterator& other)
- : ValueIteratorBase(other) {}
+ : ValueIteratorBase(other) {
+ throwRuntimeError("ConstIterator to Iterator should never be allowed.");
+}
ValueIterator::ValueIterator(const ValueIterator& other)
: ValueIteratorBase(other) {}
#include <limits>
#include <sstream>
#include <string>
-#include <iostream>
#include <iomanip>
// Make numeric limits more convenient to talk about.
JSONTEST_FIXTURE(IteratorTest, const) {
Json::Value const v;
- Json::Value::iterator it = v.begin(); // This *should not* compile, but does.
+ JSONTEST_ASSERT_THROWS(
+ Json::Value::iterator it(v.begin()) // Compile, but throw.
+ );
Json::Value value;