apply clang-tidy modernize-use-override
[folly.git] / folly / ExceptionWrapper.h
index c305e688d79fa750b9e61bae02c0026750d2f07d..b00dc77d213a8e6e5efcf5d0187a4ccd3ca199a6 100644 (file)
@@ -414,7 +414,7 @@ class exception_wrapper final {
       class Ex,
       class Ex_ = _t<std::decay<Ex>>,
       FOLLY_REQUIRES(
-          Conjunction<IsStdException<Ex_>, IsRegularExceptionType<Ex_>>())>
+          Conjunction<IsStdException<Ex_>, IsRegularExceptionType<Ex_>>::value)>
   /* implicit */ exception_wrapper(Ex&& ex);
 
   //! \pre `typeid(ex) == typeid(typename decay<Ex>::type)`
@@ -427,7 +427,7 @@ class exception_wrapper final {
   template <
       class Ex,
       class Ex_ = _t<std::decay<Ex>>,
-      FOLLY_REQUIRES(IsRegularExceptionType<Ex_>())>
+      FOLLY_REQUIRES(IsRegularExceptionType<Ex_>::value)>
   exception_wrapper(in_place_t, Ex&& ex);
 
   //! Swaps the value of `*this` with the value of `that`
@@ -457,6 +457,18 @@ class exception_wrapper final {
   //! \overload
   std::exception const* get_exception() const noexcept;
 
+  //! \returns a pointer to the `Ex` held by `*this`, if it holds an object
+  //!     whose type `From` permits `std::is_convertible<From*, Ex*>`;
+  //!     otherwise, returns `nullptr`.
+  //! \note This function does not mutate the `exception_wrapper` object.
+  //! \note This function may cause an exception to be thrown and immediately
+  //!     caught internally, affecting runtime performance.
+  template <typename Ex>
+  Ex* get_exception() noexcept;
+  //! \overload
+  template <typename Ex>
+  Ex const* get_exception() const noexcept;
+
   //! \return A `std::exception_ptr` that references either the exception held
   //!     by `*this`, or a copy of same.
   //! \note This function may need to throw an exception to complete the action.
@@ -501,11 +513,6 @@ class exception_wrapper final {
   //! Throws the wrapped expression.
   [[noreturn]] void throw_exception() const;
 
-  [[noreturn]] FOLLY_DEPRECATED(
-      "use throw_exception") void throwException() const {
-    throw_exception();
-  }
-
   //! Call `fn` with the wrapped exception (if any), if `fn` can accept it.
   //! \par Example
   //! \code