aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTor Egge <Tor.Egge@online.no>2021-04-08 16:50:37 +0200
committerTor Egge <Tor.Egge@online.no>2021-04-08 16:50:37 +0200
commit2ff17d7a8f4669a44bb60def6757dec88b2d1290 (patch)
tree863efc3b22b0a55062b7552674c662c391e73f90
parent248b9d5278345c4932b6cc9f598e3943be44b850 (diff)
Avoid noncompliant use of std::is_sorted (The comparison function did not
satisfy the requirements for Compare.). Use std::adjacent_find instead.
-rw-r--r--searchlib/src/tests/attribute/enumeratedsave/enumeratedsave_test.cpp2
-rw-r--r--searchlib/src/vespa/searchlib/attribute/enum_store_loaders.cpp4
2 files changed, 4 insertions, 2 deletions
diff --git a/searchlib/src/tests/attribute/enumeratedsave/enumeratedsave_test.cpp b/searchlib/src/tests/attribute/enumeratedsave/enumeratedsave_test.cpp
index 7677a71ba3a..dadf3f21297 100644
--- a/searchlib/src/tests/attribute/enumeratedsave/enumeratedsave_test.cpp
+++ b/searchlib/src/tests/attribute/enumeratedsave/enumeratedsave_test.cpp
@@ -552,6 +552,8 @@ EnumeratedSaveTest::checkMem(AttributeVector &v, const MemAttr &e)
MemAttr m2;
EXPECT_TRUE(v2->save(m2, v.getBaseFileName()));
ASSERT_TRUE(m2 == e);
+ auto v3 = AttributeFactory::createAttribute("convert", v.getConfig());
+ EXPECT_TRUE(v3->load());
}
}
diff --git a/searchlib/src/vespa/searchlib/attribute/enum_store_loaders.cpp b/searchlib/src/vespa/searchlib/attribute/enum_store_loaders.cpp
index 0e8aa6ee5a8..b5b101b324b 100644
--- a/searchlib/src/vespa/searchlib/attribute/enum_store_loaders.cpp
+++ b/searchlib/src/vespa/searchlib/attribute/enum_store_loaders.cpp
@@ -43,7 +43,7 @@ EnumeratedLoaderBase::build_enum_value_remapping()
}
auto comp_up = _store.allocate_comparator();
auto& comp = *comp_up;
- if (std::is_sorted(_indexes.begin(), _indexes.end(), [&comp](Index lhs, Index rhs) { return !comp.less(rhs, lhs); })) {
+ if (std::adjacent_find(_indexes.begin(), _indexes.end(), [&comp](Index lhs, Index rhs) { return !comp.less(lhs, rhs); }) == _indexes.end()) {
return; // Unique values are already sorted
}
vespalib::Array<std::pair<Index, uint32_t>> sortdata;
@@ -61,7 +61,7 @@ EnumeratedLoaderBase::build_enum_value_remapping()
_enum_value_remapping[entry.second] = enum_value;
++enum_value;
}
- assert(std::is_sorted(_indexes.begin(), _indexes.end(), [&comp](Index lhs, Index rhs) { return !comp.less(rhs, lhs); }));
+ assert(std::adjacent_find(_indexes.begin(), _indexes.end(), [&comp](Index lhs, Index rhs) { return !comp.less(lhs, rhs); }) == _indexes.end());
}
void