util: backport std::to_underlying()

Change-Id: I239ceb6be20d56343917cfcd7e1049fc852c1ced
diff --git a/ndn-cxx/name-component.cpp b/ndn-cxx/name-component.cpp
index b19eacc..b7b9333 100644
--- a/ndn-cxx/name-component.cpp
+++ b/ndn-cxx/name-component.cpp
@@ -77,13 +77,13 @@
 static bool
 canDecodeMarkerConvention()
 {
-  return (static_cast<int>(g_conventionDecoding) & static_cast<int>(Convention::MARKER)) != 0;
+  return (to_underlying(g_conventionDecoding) & to_underlying(Convention::MARKER)) != 0;
 }
 
 static bool
 canDecodeTypedConvention()
 {
-  return (static_cast<int>(g_conventionDecoding) & static_cast<int>(Convention::TYPED)) != 0;
+  return (to_underlying(g_conventionDecoding) & to_underlying(Convention::TYPED)) != 0;
 }
 
 void