util: backport scope_exit & co. from the Library Fundamentals TS v3
Implementation taken from scope-lite by Martin Moene,
commit 197cd4240069b2b8c393ad0d9eabdee601b606b4
Change-Id: I872b6821504b3270ebdc4c48b7255731fb2efc57
diff --git a/tests/unit/security/certificate-fetcher-offline.t.cpp b/tests/unit/security/certificate-fetcher-offline.t.cpp
index e3ca483..ac1e9ee 100644
--- a/tests/unit/security/certificate-fetcher-offline.t.cpp
+++ b/tests/unit/security/certificate-fetcher-offline.t.cpp
@@ -21,12 +21,11 @@
#include "ndn-cxx/security/certificate-fetcher-offline.hpp"
#include "ndn-cxx/security/validation-policy-simple-hierarchy.hpp"
+#include "ndn-cxx/util/scope.hpp"
#include "tests/boost-test.hpp"
#include "tests/unit/security/validator-fixture.hpp"
-#include <boost/scope_exit.hpp>
-
namespace ndn {
namespace security {
inline namespace v2 {
@@ -49,15 +48,13 @@
BOOST_FIXTURE_TEST_SUITE(TestCertificateFetcherOffline, CertificateFetcherOfflineFixture)
-typedef boost::mpl::vector<Interest, Data> Packets;
+using Packets = boost::mpl::vector<Interest, Data>;
BOOST_AUTO_TEST_CASE_TEMPLATE(Validate, Packet, Packets)
{
// Can't set CanBePrefix on Interests in this test case because of template
// TODO: Remove in #4582
- BOOST_SCOPE_EXIT(void) {
- Interest::s_errorIfCanBePrefixUnset = true;
- } BOOST_SCOPE_EXIT_END
+ auto guard = make_scope_exit([] { Interest::s_errorIfCanBePrefixUnset = true; });
Interest::s_errorIfCanBePrefixUnset = false;
Packet unsignedPacket("/Security/ValidatorFixture/Sub1/Packet");