Use more C++17 features
Mainly structured bindings, inline variables, and class template
argument deduction, plus many more smaller things.
Change-Id: I810d17e0adb470426e4e30c898e03b3140ad052f
diff --git a/tests/core/algorithm.t.cpp b/tests/core/algorithm.t.cpp
index fb23238..89a60ba 100644
--- a/tests/core/algorithm.t.cpp
+++ b/tests/core/algorithm.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2019, Regents of the University of California,
+ * Copyright (c) 2014-2022, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -34,24 +34,22 @@
BOOST_AUTO_TEST_CASE(FindLastIf)
{
- std::vector<int> vec{1, 2, 3, 4, 5, 6, 7, 8, 9};
+ const std::vector<int> vec{1, 2, 3, 4, 5, 6, 7, 8, 9};
int hit1 = 0;
- std::vector<int>::const_iterator found1 = find_last_if(vec.begin(), vec.end(),
- [&hit1] (int n) -> bool {
- ++hit1;
- return n % 2 == 0;
- });
+ auto found1 = find_last_if(vec.begin(), vec.end(), [&hit1] (int n) -> bool {
+ ++hit1;
+ return n % 2 == 0;
+ });
BOOST_REQUIRE(found1 != vec.end());
BOOST_CHECK_EQUAL(*found1, 8);
BOOST_CHECK_LE(hit1, vec.size());
int hit2 = 0;
- std::vector<int>::const_iterator found2 = find_last_if(vec.begin(), vec.end(),
- [&hit2] (int n) -> bool {
- ++hit2;
- return n < 0;
- });
+ auto found2 = find_last_if(vec.begin(), vec.end(), [&hit2] (int n) -> bool {
+ ++hit2;
+ return n < 0;
+ });
BOOST_CHECK(found2 == vec.end());
BOOST_CHECK_LE(hit2, vec.size());
}
diff --git a/tests/core/version.t.cpp b/tests/core/version.t.cpp
index 6024f8c..349dfff 100644
--- a/tests/core/version.t.cpp
+++ b/tests/core/version.t.cpp
@@ -43,9 +43,9 @@
NFD_VERSION_MINOR * 1000 +
NFD_VERSION_PATCH);
- static_assert(NFD_VERSION_MAJOR >= 22 && NFD_VERSION_MAJOR <= 100, "");
- static_assert(NFD_VERSION_MINOR >= 1 && NFD_VERSION_MINOR <= 12, "");
- static_assert(NFD_VERSION_PATCH < 1000, "");
+ static_assert(NFD_VERSION_MAJOR >= 22 && NFD_VERSION_MAJOR <= 100);
+ static_assert(NFD_VERSION_MINOR >= 1 && NFD_VERSION_MINOR <= 12);
+ static_assert(NFD_VERSION_PATCH < 1000);
}
BOOST_AUTO_TEST_CASE(VersionString)