util: make overload() function public

Rename backports-ostream-joiner.hpp to ostream-joiner.hpp
and deprecate its inclusion from backports.hpp

Change-Id: I1df03506e92da97a98871a56787e346ae328323d
diff --git a/ndn-cxx/delegation-list.cpp b/ndn-cxx/delegation-list.cpp
index 47cf021..a051124 100644
--- a/ndn-cxx/delegation-list.cpp
+++ b/ndn-cxx/delegation-list.cpp
@@ -20,6 +20,7 @@
  */
 
 #include "ndn-cxx/delegation-list.hpp"
+#include "ndn-cxx/util/ostream-joiner.hpp"
 
 namespace ndn {
 
diff --git a/ndn-cxx/encoding/block.cpp b/ndn-cxx/encoding/block.cpp
index cd90b1f..4f6d8c8 100644
--- a/ndn-cxx/encoding/block.cpp
+++ b/ndn-cxx/encoding/block.cpp
@@ -26,6 +26,7 @@
 #include "ndn-cxx/encoding/encoding-buffer.hpp"
 #include "ndn-cxx/encoding/tlv.hpp"
 #include "ndn-cxx/security/transform.hpp"
+#include "ndn-cxx/util/ostream-joiner.hpp"
 #include "ndn-cxx/util/string-helper.hpp"
 
 #include <boost/asio/buffer.hpp>
diff --git a/ndn-cxx/encoding/nfd-constants.cpp b/ndn-cxx/encoding/nfd-constants.cpp
index 83d3122..9547351 100644
--- a/ndn-cxx/encoding/nfd-constants.cpp
+++ b/ndn-cxx/encoding/nfd-constants.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2013-2018 Regents of the University of California.
+ * Copyright (c) 2013-2019 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -20,6 +20,7 @@
  */
 
 #include "ndn-cxx/encoding/nfd-constants.hpp"
+#include "ndn-cxx/util/ostream-joiner.hpp"
 #include "ndn-cxx/util/string-helper.hpp"
 
 #include <boost/algorithm/string.hpp>
diff --git a/ndn-cxx/key-locator.cpp b/ndn-cxx/key-locator.cpp
index 2084dc1..88b7f03 100644
--- a/ndn-cxx/key-locator.cpp
+++ b/ndn-cxx/key-locator.cpp
@@ -20,8 +20,8 @@
  */
 
 #include "ndn-cxx/key-locator.hpp"
-#include "ndn-cxx/detail/overload.hpp"
 #include "ndn-cxx/encoding/block-helpers.hpp"
+#include "ndn-cxx/util/overload.hpp"
 #include "ndn-cxx/util/string-helper.hpp"
 
 namespace ndn {
@@ -56,7 +56,7 @@
 
   size_t totalLength = 0;
 
-  auto visitor = detail::overload(
+  auto visitor = overload(
     []  (monostate)           {}, // nothing to encode, TLV-VALUE is empty
     [&] (const Name& name)    { totalLength += name.wireEncode(encoder); },
     [&] (const Block& digest) { totalLength += encoder.prependBlock(digest); },
@@ -192,7 +192,7 @@
 std::ostream&
 operator<<(std::ostream& os, const KeyLocator& keyLocator)
 {
-  auto visitor = detail::overload(
+  auto visitor = overload(
     [&] (monostate) {
       os << "None";
     },
diff --git a/ndn-cxx/mgmt/nfd/fib-entry.cpp b/ndn-cxx/mgmt/nfd/fib-entry.cpp
index 94154e3..e5438eb 100644
--- a/ndn-cxx/mgmt/nfd/fib-entry.cpp
+++ b/ndn-cxx/mgmt/nfd/fib-entry.cpp
@@ -24,6 +24,7 @@
 #include "ndn-cxx/encoding/encoding-buffer.hpp"
 #include "ndn-cxx/encoding/tlv-nfd.hpp"
 #include "ndn-cxx/util/concepts.hpp"
+#include "ndn-cxx/util/ostream-joiner.hpp"
 
 #include <boost/range/adaptor/reversed.hpp>
 
diff --git a/ndn-cxx/mgmt/nfd/rib-entry.cpp b/ndn-cxx/mgmt/nfd/rib-entry.cpp
index f565acb..a3551d0 100644
--- a/ndn-cxx/mgmt/nfd/rib-entry.cpp
+++ b/ndn-cxx/mgmt/nfd/rib-entry.cpp
@@ -24,6 +24,7 @@
 #include "ndn-cxx/encoding/encoding-buffer.hpp"
 #include "ndn-cxx/encoding/tlv-nfd.hpp"
 #include "ndn-cxx/util/concepts.hpp"
+#include "ndn-cxx/util/ostream-joiner.hpp"
 #include "ndn-cxx/util/string-helper.hpp"
 
 #include <boost/range/adaptor/reversed.hpp>
diff --git a/ndn-cxx/security/v2/additional-description.cpp b/ndn-cxx/security/v2/additional-description.cpp
index 9c03758..f9aa2af 100644
--- a/ndn-cxx/security/v2/additional-description.cpp
+++ b/ndn-cxx/security/v2/additional-description.cpp
@@ -22,6 +22,7 @@
 #include "ndn-cxx/security/v2/additional-description.hpp"
 #include "ndn-cxx/encoding/block-helpers.hpp"
 #include "ndn-cxx/util/concepts.hpp"
+#include "ndn-cxx/util/ostream-joiner.hpp"
 
 namespace ndn {
 namespace security {
diff --git a/ndn-cxx/security/v2/certificate.cpp b/ndn-cxx/security/v2/certificate.cpp
index 9883825..83e1656 100644
--- a/ndn-cxx/security/v2/certificate.cpp
+++ b/ndn-cxx/security/v2/certificate.cpp
@@ -170,8 +170,8 @@
 
     if (cert.getSignature().hasKeyLocator()) {
       os << "  Key Locator: ";
-      const KeyLocator& keyLocator = cert.getSignature().getKeyLocator();
-      if (keyLocator.getType() == KeyLocator::KeyLocator_Name && keyLocator.getName() == cert.getKeyName()) {
+      const auto& keyLocator = cert.getSignature().getKeyLocator();
+      if (keyLocator.getType() == tlv::Name && keyLocator.getName() == cert.getKeyName()) {
         os << "Self-Signed ";
       }
       os << keyLocator << "\n";
diff --git a/ndn-cxx/security/v2/validation-policy.cpp b/ndn-cxx/security/v2/validation-policy.cpp
index f182108..23a63e2 100644
--- a/ndn-cxx/security/v2/validation-policy.cpp
+++ b/ndn-cxx/security/v2/validation-policy.cpp
@@ -73,7 +73,7 @@
   }
 
   const KeyLocator& kl = si.getKeyLocator();
-  if (kl.getType() != KeyLocator::KeyLocator_Name) {
+  if (kl.getType() != tlv::Name) {
     state.fail({ValidationError::Code::INVALID_KEY_LOCATOR, "KeyLocator type is not Name"});
     return Name();
   }
diff --git a/ndn-cxx/util/backports.hpp b/ndn-cxx/util/backports.hpp
index 22a484e..aac4eb6 100644
--- a/ndn-cxx/util/backports.hpp
+++ b/ndn-cxx/util/backports.hpp
@@ -79,10 +79,10 @@
 #  define NDN_CXX_UNREACHABLE std::abort()
 #endif
 
-#include "ndn-cxx/util/backports-ostream-joiner.hpp"
 #include "ndn-cxx/util/nonstd/any.hpp"
 #include "ndn-cxx/util/nonstd/optional.hpp"
 #include "ndn-cxx/util/nonstd/variant.hpp"
+#include "ndn-cxx/util/ostream-joiner.hpp"
 
 #ifndef NDN_CXX_HAVE_STD_TO_STRING
 #include <boost/lexical_cast.hpp>
diff --git a/ndn-cxx/util/backports-ostream-joiner.hpp b/ndn-cxx/util/ostream-joiner.hpp
similarity index 91%
rename from ndn-cxx/util/backports-ostream-joiner.hpp
rename to ndn-cxx/util/ostream-joiner.hpp
index a05e841..8586bd9 100644
--- a/ndn-cxx/util/backports-ostream-joiner.hpp
+++ b/ndn-cxx/util/ostream-joiner.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2013-2018 Regents of the University of California.
+ * Copyright (c) 2013-2019 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -21,11 +21,11 @@
 
 /** \file
  *  \brief Backport of ostream_joiner from the Library Fundamentals v2 TS
- *  \sa http://en.cppreference.com/w/cpp/experimental/ostream_joiner
+ *  \sa https://en.cppreference.com/w/cpp/experimental/ostream_joiner
  */
 
-#ifndef NDN_UTIL_BACKPORTS_OSTREAM_JOINER_HPP
-#define NDN_UTIL_BACKPORTS_OSTREAM_JOINER_HPP
+#ifndef NDN_UTIL_OSTREAM_JOINER_HPP
+#define NDN_UTIL_OSTREAM_JOINER_HPP
 
 #include "ndn-cxx/util/backports.hpp"
 
@@ -122,4 +122,4 @@
 } // namespace ndn
 
 #endif // NDN_CXX_HAVE_EXPERIMENTAL_OSTREAM_JOINER
-#endif // NDN_UTIL_BACKPORTS_OSTREAM_JOINER_HPP
+#endif // NDN_UTIL_OSTREAM_JOINER_HPP
diff --git a/ndn-cxx/detail/overload.hpp b/ndn-cxx/util/overload.hpp
similarity index 90%
rename from ndn-cxx/detail/overload.hpp
rename to ndn-cxx/util/overload.hpp
index a12c9d8..228c684 100644
--- a/ndn-cxx/detail/overload.hpp
+++ b/ndn-cxx/util/overload.hpp
@@ -19,26 +19,27 @@
  * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
  */
 
-#ifndef NDN_DETAIL_OVERLOAD_HPP
-#define NDN_DETAIL_OVERLOAD_HPP
+#ifndef NDN_UTIL_OVERLOAD_HPP
+#define NDN_UTIL_OVERLOAD_HPP
 
+#include <boost/predef/compiler/gcc.h>
 #include <boost/version.hpp>
 
-#if BOOST_VERSION >= 106100
+// Hana does not support GCC < 6.0.0
+#if (BOOST_VERSION >= 106100) && (!BOOST_COMP_GNUC || (BOOST_COMP_GNUC >= BOOST_VERSION_NUMBER(6,0,0)))
+
 #include <boost/hana/functional/overload.hpp>
 
 namespace ndn {
-namespace detail {
 constexpr boost::hana::make_overload_t overload{};
-} // namespace detail
 } // namespace ndn
 
 #else
+
 #include <type_traits>
 
 namespace ndn {
 namespace detail {
-namespace hana_backports {
 
 // The following code is copied from the Boost.Hana library.
 // Copyright Louis Dionne 2013-2017
@@ -102,12 +103,11 @@
 };
 #endif // DOXYGEN
 
-} // namespace hana_backports
-
-constexpr hana_backports::make_overload_t overload{};
-
 } // namespace detail
+
+constexpr detail::make_overload_t overload{};
+
 } // namespace ndn
 
 #endif // BOOST_VERSION >= 106100
-#endif // NDN_DETAIL_OVERLOAD_HPP
+#endif // NDN_UTIL_OVERLOAD_HPP
diff --git a/tests/unit/util/backports.t.cpp b/tests/unit/util/backports.t.cpp
index 6ff2c4c..8f80263 100644
--- a/tests/unit/util/backports.t.cpp
+++ b/tests/unit/util/backports.t.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2013-2018 Regents of the University of California.
+ * Copyright (c) 2013-2019 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -20,6 +20,7 @@
  */
 
 #include "ndn-cxx/util/backports.hpp"
+#include "ndn-cxx/util/ostream-joiner.hpp"
 
 #include "tests/boost-test.hpp"