Improve and simplify code with modern C++ features

Change-Id: I28d84df3087492ab2ecbeb91169a2cde12c9e31e
diff --git a/src/encoding/block-helpers.hpp b/src/encoding/block-helpers.hpp
index c66c0b9..acde49c 100644
--- a/src/encoding/block-helpers.hpp
+++ b/src/encoding/block-helpers.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).
  *
@@ -68,7 +68,7 @@
  *                    represented in R
  */
 template<typename R>
-typename std::enable_if<std::is_integral<R>::value, R>::type
+std::enable_if_t<std::is_integral<R>::value, R>
 readNonNegativeIntegerAs(const Block& block)
 {
   uint64_t value = readNonNegativeInteger(block);
@@ -88,10 +88,10 @@
  *           function may trigger unspecified behavior.
  */
 template<typename R>
-typename std::enable_if<std::is_enum<R>::value, R>::type
+std::enable_if_t<std::is_enum<R>::value, R>
 readNonNegativeIntegerAs(const Block& block)
 {
-  return static_cast<R>(readNonNegativeIntegerAs<typename std::underlying_type<R>::type>(block));
+  return static_cast<R>(readNonNegativeIntegerAs<std::underlying_type_t<R>>(block));
 }
 
 /** @brief Prepend an empty TLV element
@@ -231,11 +231,11 @@
 Block
 makeBinaryBlock(uint32_t type, Iterator first, Iterator last)
 {
-  using BinaryBlockHelper = typename std::conditional<
+  using BinaryBlockHelper = std::conditional_t<
     std::is_base_of<std::random_access_iterator_tag,
                     typename std::iterator_traits<Iterator>::iterator_category>::value,
     detail::BinaryBlockFast<Iterator>,
-    detail::BinaryBlockSlow<Iterator>>::type;
+    detail::BinaryBlockSlow<Iterator>>;
 
   return BinaryBlockHelper::makeBlock(type, first, last);
 }
diff --git a/src/encoding/nfd-constants.cpp b/src/encoding/nfd-constants.cpp
index 5c3189a..eebd4f3 100644
--- a/src/encoding/nfd-constants.cpp
+++ b/src/encoding/nfd-constants.cpp
@@ -121,7 +121,7 @@
     routeOrigin = ROUTE_ORIGIN_STATIC;
   else {
     // To reject negative numbers, we parse as a wider signed type, and compare with the range.
-    static_assert(std::numeric_limits<std::underlying_type<RouteOrigin>::type>::max() <=
+    static_assert(std::numeric_limits<std::underlying_type_t<RouteOrigin>>::max() <=
                   std::numeric_limits<int>::max(), "");
 
     int v = -1;
@@ -131,8 +131,8 @@
     catch (const boost::bad_lexical_cast&) {
     }
 
-    if (v >= std::numeric_limits<std::underlying_type<RouteOrigin>::type>::min() &&
-        v <= std::numeric_limits<std::underlying_type<RouteOrigin>::type>::max()) {
+    if (v >= std::numeric_limits<std::underlying_type_t<RouteOrigin>>::min() &&
+        v <= std::numeric_limits<std::underlying_type_t<RouteOrigin>>::max()) {
       routeOrigin = static_cast<RouteOrigin>(v);
     }
     else {
diff --git a/src/encoding/tlv.hpp b/src/encoding/tlv.hpp
index fc664c6..6a14a7c 100644
--- a/src/encoding/tlv.hpp
+++ b/src/encoding/tlv.hpp
@@ -354,7 +354,7 @@
  *  common ContiguousIterator types used with TLV decoding function templates.
  */
 template<typename Iterator,
-         typename DecayedIterator = typename std::decay<Iterator>::type,
+         typename DecayedIterator = std::decay_t<Iterator>,
          typename ValueType = typename std::iterator_traits<DecayedIterator>::value_type>
 constexpr bool
 shouldSelectContiguousReadNumber()
@@ -367,8 +367,8 @@
 }
 
 template<typename Iterator>
-class ReadNumber : public std::conditional<shouldSelectContiguousReadNumber<Iterator>(),
-                                           ReadNumberFast<Iterator>, ReadNumberSlow<Iterator>>::type
+class ReadNumber : public std::conditional_t<shouldSelectContiguousReadNumber<Iterator>(),
+                                             ReadNumberFast<Iterator>, ReadNumberSlow<Iterator>>
 {
 };