util: backport optional::reset

refs #3753

Change-Id: I17e77d7b7e3c450fc86aec06f5c2d3ecfcc1444a
diff --git a/src/util/backports-optional.hpp b/src/util/backports-optional.hpp
index 8f1f498..accae69 100644
--- a/src/util/backports-optional.hpp
+++ b/src/util/backports-optional.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2013-2017 Regents of the University of California.
+ * Copyright (c) 2013-2018 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -269,6 +269,12 @@
     boost::swap(m_boostOptional, other.m_boostOptional);
   }
 
+  void
+  reset() noexcept
+  {
+    m_boostOptional = boost::none;
+  }
+
   template<typename... Args>
   void
   emplace(Args&&... args)
diff --git a/tests/unit-tests/util/backports.t.cpp b/tests/unit-tests/util/backports.t.cpp
index 3722834..629c3ee 100644
--- a/tests/unit-tests/util/backports.t.cpp
+++ b/tests/unit-tests/util/backports.t.cpp
@@ -226,6 +226,13 @@
   BOOST_CHECK_EQUAL(static_cast<bool>(o2), false);
 }
 
+BOOST_AUTO_TEST_CASE(Reset)
+{
+  optional<int> o1(1);
+  o1.reset();
+  BOOST_CHECK_EQUAL(static_cast<bool>(o1), false);
+}
+
 BOOST_AUTO_TEST_CASE(Emplace)
 {
   optional<std::pair<int, int>> o1;