build: require gcc >= 5.3, boost >= 1.58, openssl >= 1.0.2

This effectively drops support for all versions of Ubuntu older than 16.04

Change-Id: Ie3ab7df9147e97f6467658a6399a4f9379f089c1
Refs: #4462
diff --git a/src/encoding/block.cpp b/src/encoding/block.cpp
index 2113064..ed8f5c9 100644
--- a/src/encoding/block.cpp
+++ b/src/encoding/block.cpp
@@ -34,15 +34,10 @@
 namespace ndn {
 
 BOOST_CONCEPT_ASSERT((boost::EqualityComparable<Block>));
-#if NDN_CXX_HAVE_IS_NOTHROW_MOVE_CONSTRUCTIBLE
 static_assert(std::is_nothrow_move_constructible<Block>::value,
               "Block must be MoveConstructible with noexcept");
-#endif // NDN_CXX_HAVE_IS_NOTHROW_MOVE_CONSTRUCTIBLE
-
-#if NDN_CXX_HAVE_IS_NOTHROW_MOVE_ASSIGNABLE
 static_assert(std::is_nothrow_move_assignable<Block>::value,
               "Block must be MoveAssignable with noexcept");
-#endif // NDN_CXX_HAVE_IS_NOTHROW_MOVE_ASSIGNABLE
 
 const size_t MAX_SIZE_OF_BLOCK_FROM_STREAM = MAX_NDN_PACKET_SIZE;
 
@@ -454,30 +449,14 @@
 Block::erase(Block::element_const_iterator position)
 {
   resetWire();
-
-#ifdef NDN_CXX_HAVE_VECTOR_INSERT_ERASE_CONST_ITERATOR
   return m_elements.erase(position);
-#else
-  element_iterator it = m_elements.begin();
-  std::advance(it, std::distance(m_elements.cbegin(), position));
-  return m_elements.erase(it);
-#endif
 }
 
 Block::element_iterator
 Block::erase(Block::element_const_iterator first, Block::element_const_iterator last)
 {
   resetWire();
-
-#ifdef NDN_CXX_HAVE_VECTOR_INSERT_ERASE_CONST_ITERATOR
   return m_elements.erase(first, last);
-#else
-  element_iterator itStart = m_elements.begin();
-  element_iterator itEnd = m_elements.begin();
-  std::advance(itStart, std::distance(m_elements.cbegin(), first));
-  std::advance(itEnd, std::distance(m_elements.cbegin(), last));
-  return m_elements.erase(itStart, itEnd);
-#endif
 }
 
 void
@@ -491,14 +470,7 @@
 Block::insert(Block::element_const_iterator pos, const Block& element)
 {
   resetWire();
-
-#ifdef NDN_CXX_HAVE_VECTOR_INSERT_ERASE_CONST_ITERATOR
   return m_elements.insert(pos, element);
-#else
-  element_iterator it = m_elements.begin();
-  std::advance(it, std::distance(m_elements.cbegin(), pos));
-  return m_elements.insert(it, element);
-#endif
 }
 
 // ---- misc ----
diff --git a/src/encoding/buffer.cpp b/src/encoding/buffer.cpp
index ce4c880..531e9fa 100644
--- a/src/encoding/buffer.cpp
+++ b/src/encoding/buffer.cpp
@@ -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).
  *
@@ -25,15 +25,10 @@
 
 namespace ndn {
 
-#if NDN_CXX_HAVE_IS_NOTHROW_MOVE_CONSTRUCTIBLE
 static_assert(std::is_nothrow_move_constructible<Buffer>::value,
               "Buffer must be MoveConstructible with noexcept");
-#endif // NDN_CXX_HAVE_IS_NOTHROW_MOVE_CONSTRUCTIBLE
-
-#if NDN_CXX_HAVE_IS_NOTHROW_MOVE_ASSIGNABLE
 static_assert(std::is_nothrow_move_assignable<Buffer>::value,
               "Buffer must be MoveAssignable with noexcept");
-#endif // NDN_CXX_HAVE_IS_NOTHROW_MOVE_ASSIGNABLE
 
 Buffer::Buffer() = default;
 
diff --git a/src/net/address-converter.cpp b/src/net/address-converter.cpp
index d84f757..e29c0c0 100644
--- a/src/net/address-converter.cpp
+++ b/src/net/address-converter.cpp
@@ -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,
  *                         Arizona Board of Regents,
  *                         Colorado State University,
  *                         University Pierre & Marie Curie, Sorbonne University,
@@ -27,13 +27,7 @@
 
 #include "address-converter.hpp"
 
-#if BOOST_VERSION < 105800
-#include <boost/algorithm/string.hpp>
-#include <boost/lexical_cast.hpp>
-#include <vector>
-#endif // BOOST_VERSION < 105800
-
-#include <net/if.h> // for if_nametoindex and if_indextoname
+#include <net/if.h> // for if_indextoname()
 
 namespace ndn {
 namespace ip {
@@ -49,69 +43,10 @@
   return nullopt;
 }
 
-#if BOOST_VERSION < 105800
-static unsigned int
-scopeIdFromString(const std::string& scope)
-{
-  auto id = if_nametoindex(scope.c_str());
-  if (id != 0) {
-    return id;
-  }
-
-  // cannot find a corresponding index, assume it's not a name but an interface index
-  try {
-    return boost::lexical_cast<unsigned int>(scope);
-  }
-  catch (const boost::bad_lexical_cast&) {
-    return 0;
-  }
-}
-
-struct ParsedAddress
-{
-  boost::asio::ip::address addr;
-  std::string scope;
-};
-
-static ParsedAddress
-parseAddressFromString(const std::string& address, boost::system::error_code& ec)
-{
-  std::vector<std::string> parseResult;
-  boost::algorithm::split(parseResult, address, boost::is_any_of("%"));
-  auto addr = boost::asio::ip::address::from_string(parseResult[0], ec);
-
-  switch (parseResult.size()) {
-  case 1:
-    // regular address
-    return {addr, ""};
-  case 2:
-    // the presence of % in either an IPv4 address or a regular IPv6 address is invalid
-    if (!ec && addr.is_v6() && addr.to_v6().is_link_local()) {
-      return {addr, parseResult[1]};
-    }
-    NDN_CXX_FALLTHROUGH;
-  default:
-    ec = boost::asio::error::invalid_argument;
-    return {};
-  }
-}
-#endif // BOOST_VERSION < 105800
-
 boost::asio::ip::address
 addressFromString(const std::string& address, boost::system::error_code& ec)
 {
-  // boost < 1.58 cannot recognize scope-id in link-local IPv6 address
-#if BOOST_VERSION < 105800
-  auto parsedAddress = parseAddressFromString(address, ec);
-  if (ec || parsedAddress.addr.is_v4()) {
-    return parsedAddress.addr;
-  }
-  auto addr = parsedAddress.addr.to_v6();
-  addr.scope_id(scopeIdFromString(parsedAddress.scope));
-  return addr;
-#else
   return boost::asio::ip::address::from_string(address, ec);
-#endif // BOOST_VERSION < 105800
 }
 
 boost::asio::ip::address
diff --git a/src/security/transform/verifier-filter.cpp b/src/security/transform/verifier-filter.cpp
index fca982a..f4b8e84 100644
--- a/src/security/transform/verifier-filter.cpp
+++ b/src/security/transform/verifier-filter.cpp
@@ -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).
  *
@@ -75,13 +75,7 @@
 void
 VerifierFilter::finalize()
 {
-  int res = EVP_DigestVerifyFinal(m_impl->ctx,
-#if OPENSSL_VERSION_NUMBER < 0x1000200fL
-                                  const_cast<uint8_t*>(m_impl->sig),
-#else
-                                  m_impl->sig,
-#endif
-                                  m_impl->siglen);
+  int res = EVP_DigestVerifyFinal(m_impl->ctx, m_impl->sig, m_impl->siglen);
 
   auto buffer = make_unique<OBuffer>(1);
   (*buffer)[0] = (res == 1) ? 1 : 0;
diff --git a/src/util/backports-optional.hpp b/src/util/backports-optional.hpp
index accae69..73e1068 100644
--- a/src/util/backports-optional.hpp
+++ b/src/util/backports-optional.hpp
@@ -107,18 +107,7 @@
 };
 constexpr nullopt_t nullopt{0};
 
-#if BOOST_VERSION >= 105600
 using boost::bad_optional_access;
-#else
-class bad_optional_access : public std::logic_error
-{
-public:
-  bad_optional_access()
-    : std::logic_error("bad optional access")
-  {
-  }
-};
-#endif
 
 template<typename T>
 constexpr bool
@@ -241,25 +230,14 @@
   T&
   value()
   {
-#if BOOST_VERSION >= 105600
     return m_boostOptional.value();
-#else
-    if (!m_boostOptional) {
-      BOOST_THROW_EXCEPTION(bad_optional_access());
-    }
-    return m_boostOptional.get();
-#endif
   }
 
   template<typename U>
   constexpr T
   value_or(U&& default_value) const
   {
-#if BOOST_VERSION >= 105600
     return m_boostOptional.value_or(default_value);
-#else
-    return m_boostOptional.get_value_or(default_value);
-#endif
   }
 
 public: // modifiers
diff --git a/src/util/regex/regex-component-matcher.cpp b/src/util/regex/regex-component-matcher.cpp
index 8d1e824..aca35c1 100644
--- a/src/util/regex/regex-component-matcher.cpp
+++ b/src/util/regex/regex-component-matcher.cpp
@@ -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).
  *
@@ -26,19 +26,6 @@
 
 namespace ndn {
 
-// Re: http://www.boost.org/users/history/version_1_56_0.html
-//
-//   Breaking change: corrected behavior of basic_regex<>::mark_count() to match existing
-//   documentation, basic_regex<>::subexpression(n) changed to match, see
-//   https://svn.boost.org/trac/boost/ticket/9227
-//
-static constexpr size_t BOOST_REGEXP_MARK_COUNT_CORRECTION =
-#if BOOST_VERSION < 105600
-    1;
-#else
-    0;
-#endif
-
 RegexComponentMatcher::RegexComponentMatcher(const std::string& expr,
                                              shared_ptr<RegexBackrefManager> backrefManager,
                                              bool isExactMatch)
@@ -56,7 +43,7 @@
   m_pseudoMatchers.clear();
   m_pseudoMatchers.push_back(make_shared<RegexPseudoMatcher>());
 
-  for (size_t i = 1; i <= m_componentRegex.mark_count() - BOOST_REGEXP_MARK_COUNT_CORRECTION; i++) {
+  for (size_t i = 1; i <= m_componentRegex.mark_count(); i++) {
     m_pseudoMatchers.push_back(make_shared<RegexPseudoMatcher>());
     m_backrefManager->pushRef(m_pseudoMatchers.back());
   }
@@ -78,7 +65,7 @@
   boost::smatch subResult;
   std::string targetStr = name.get(offset).toUri();
   if (boost::regex_match(targetStr, subResult, m_componentRegex)) {
-    for (size_t i = 1; i <= m_componentRegex.mark_count() - BOOST_REGEXP_MARK_COUNT_CORRECTION; i++) {
+    for (size_t i = 1; i <= m_componentRegex.mark_count(); i++) {
       m_pseudoMatchers[i]->resetMatchResult();
       m_pseudoMatchers[i]->setMatchResult(subResult[i]);
     }
diff --git a/src/util/scheduler-scoped-event-id.cpp b/src/util/scheduler-scoped-event-id.cpp
index f5378c8..0ca7d13 100644
--- a/src/util/scheduler-scoped-event-id.cpp
+++ b/src/util/scheduler-scoped-event-id.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2013-2016 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).
  *
@@ -25,10 +25,8 @@
 namespace util {
 namespace scheduler {
 
-#if NDN_CXX_HAVE_IS_NOTHROW_MOVE_CONSTRUCTIBLE
 static_assert(std::is_nothrow_move_constructible<ScopedEventId>::value,
               "ScopedEventId must be MoveConstructible with noexcept");
-#endif // NDN_CXX_HAVE_IS_NOTHROW_MOVE_CONSTRUCTIBLE
 
 ScopedEventId::ScopedEventId(Scheduler& scheduler)
   : m_scheduler(&scheduler)
diff --git a/src/util/signal/scoped-connection.cpp b/src/util/signal/scoped-connection.cpp
index cbbfaba..3fed4a3 100644
--- a/src/util/signal/scoped-connection.cpp
+++ b/src/util/signal/scoped-connection.cpp
@@ -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).
  *
@@ -25,14 +25,10 @@
 namespace util {
 namespace signal {
 
-#if NDN_CXX_HAVE_IS_NOTHROW_MOVE_CONSTRUCTIBLE
 static_assert(std::is_nothrow_move_constructible<ScopedConnection>::value,
               "ScopedConnection must be MoveConstructible with noexcept");
-#endif // NDN_CXX_HAVE_IS_NOTHROW_MOVE_CONSTRUCTIBLE
 
-ScopedConnection::ScopedConnection()
-{
-}
+ScopedConnection::ScopedConnection() = default;
 
 ScopedConnection::ScopedConnection(const Connection& connection)
   : m_connection(connection)
diff --git a/src/util/signal/signal.hpp b/src/util/signal/signal.hpp
index 9b502ab..8c76e13 100644
--- a/src/util/signal/signal.hpp
+++ b/src/util/signal/signal.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).
  *
@@ -23,6 +23,7 @@
 #define NDN_UTIL_SIGNAL_SIGNAL_HPP
 
 #include "connection.hpp"
+
 #include <list>
 
 namespace ndn {
@@ -163,7 +164,7 @@
 Connection
 Signal<Owner, TArgs...>::connect(const Handler& handler)
 {
-  typename SlotList::iterator it = m_slots.insert(m_slots.end(), {handler, nullptr});
+  auto it = m_slots.insert(m_slots.end(), {handler, nullptr});
   it->disconnect = make_shared<function<void()>>(bind(&Self::disconnect, this, it));
 
   return signal::Connection(weak_ptr<function<void()>>(it->disconnect));
@@ -173,7 +174,7 @@
 Connection
 Signal<Owner, TArgs...>::connectSingleShot(const Handler& handler)
 {
-  typename SlotList::iterator it = m_slots.insert(m_slots.end(), {nullptr, nullptr});
+  auto it = m_slots.insert(m_slots.end(), {nullptr, nullptr});
   it->disconnect = make_shared<function<void()>>(bind(&Self::disconnect, this, it));
   signal::Connection conn(weak_ptr<function<void()>>(it->disconnect));
 
@@ -189,8 +190,6 @@
 void
 Signal<Owner, TArgs...>::disconnect(typename SlotList::iterator it)
 {
-  // 'it' could be const_iterator, but gcc 4.6 doesn't support std::list::erase(const_iterator)
-
   if (m_isExecuting) {
     // during signal emission, only the currently executing handler can be disconnected
     BOOST_ASSERT_MSG(it == m_currentSlot, "cannot disconnect another handler from a handler");
diff --git a/src/util/time.hpp b/src/util/time.hpp
index cf497af..0d1250d 100644
--- a/src/util/time.hpp
+++ b/src/util/time.hpp
@@ -303,7 +303,7 @@
  * \param format desired output format (default: `%Y-%m-%d %H:%M:%S`)
  * \param locale desired locale (default: "C" locale)
  *
- * \sa http://www.boost.org/doc/libs/1_54_0/doc/html/date_time/date_time_io.html#date_time.format_flags
+ * \sa https://www.boost.org/doc/libs/1_58_0/doc/html/date_time/date_time_io.html#date_time.format_flags
  *     describes possible formatting flags
  **/
 std::string
@@ -321,7 +321,7 @@
  * \param format input output format (default: `%Y-%m-%d %H:%M:%S`)
  * \param locale input locale (default: "C" locale)
  *
- * \sa http://www.boost.org/doc/libs/1_54_0/doc/html/date_time/date_time_io.html#date_time.format_flags
+ * \sa https://www.boost.org/doc/libs/1_58_0/doc/html/date_time/date_time_io.html#date_time.format_flags
  *     describes possible formatting flags
  */
 system_clock::TimePoint