Fixing opt-asan/ubsan fail for folly contbuild
[folly.git] / folly / experimental / DynamicParser-inl.h
index f3dc0c3548985426bca80949c1327cc118b5e6fa..890b324ca96285e3ea4f0e1223d7cdec87cbb053 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2016 Facebook, Inc.
+ * Copyright 2017 Facebook, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -77,22 +77,18 @@ using ArgumentTypes =
 // extended.  The comparison deliberately strips cv-qualifieers and
 // reference, leaving that choice up to the caller.
 template <typename Fn, typename... Args>
-constexpr bool hasArgumentTypes() {
-  using HasArgumentTypes = typename boost::mpl::template equal<
-    typename boost::mpl::template transform<
-      typename boost::mpl::template transform<
-        ArgumentTypes<Fn>,
-        typename std::template remove_reference<boost::mpl::_1>
-      >::type,
-      typename std::template remove_cv<boost::mpl::_1>
-    >::type,
-    boost::mpl::vector<Args...>
-  >::type;
-  return HasArgumentTypes::value;
-}
+struct HasArgumentTypes
+    : boost::mpl::template equal<
+          typename boost::mpl::template transform<
+              typename boost::mpl::template transform<
+                  ArgumentTypes<Fn>,
+                  typename std::template remove_reference<boost::mpl::_1>>::
+                  type,
+              typename std::template remove_cv<boost::mpl::_1>>::type,
+          boost::mpl::vector<Args...>>::type {};
 template <typename... Args>
 using EnableForArgTypes =
-  typename std::enable_if<hasArgumentTypes<Args...>(), void>::type;
+    typename std::enable_if<HasArgumentTypes<Args...>::value, void>::type;
 
 // No arguments
 template <typename Fn> EnableForArgTypes<Fn>
@@ -267,11 +263,11 @@ template <typename Fn>
 void DynamicParser::wrapError(const folly::dynamic* lookup_k, Fn fn) {
   try {
     fn();
-  } catch (DynamicParserLogicError& ex) {
+  } catch (DynamicParserLogicError&) {
     // When the parser is misused, we throw all the way up to the user,
     // instead of reporting it as if the input is invalid.
     throw;
-  } catch (DynamicParserParseError& ex) {
+  } catch (DynamicParserParseError&) {
     // We are just bubbling up a parse error for OnError::THROW.
     throw;
   } catch (const std::exception& ex) {