Fixup for compilation on boost 1.57

In boost 1.57 the + and - operations are no longer overloaded on the iterator
constants by default causing the following error:

   .../include/valijson/validation_visitor.hpp:930:76:
   error: no match for ‘operator-’ (operand types are ‘const const_iterator {aka const valijson::adapters::RapidJsonArrayValueIterator}’ and ‘int’)
         const typename AdapterType::Array::const_iterator secondLast = end - 1;

The ++ operator is still valid, so here we rework in terms of it.
This commit is contained in:
Richard Clamp 2015-02-04 13:00:32 +00:00
parent 3f9183c714
commit ae4127d530

View File

@ -927,11 +927,12 @@ public:
const typename AdapterType::Array targetArray = target.getArray();
const typename AdapterType::Array::const_iterator end = targetArray.end();
const typename AdapterType::Array::const_iterator secondLast = end - 1;
const typename AdapterType::Array::const_iterator secondLast = --targetArray.end();
unsigned int outerIndex = 0;
for (typename AdapterType::Array::const_iterator outerItr = targetArray.begin(); outerItr != secondLast; ++outerItr) {
unsigned int innerIndex = 0;
for (typename AdapterType::Array::const_iterator innerItr = outerItr + 1; innerItr != end; ++innerItr) {
typename AdapterType::Array::const_iterator innerItr(outerItr);
for (++innerItr; innerItr != end; ++innerItr) {
if (outerItr->equalTo(*innerItr, true)) {
if (results) {
results->pushError(context, "Elements at indexes #" +