exception: Add ignoreQuiet functionality

Change-Id: I596c658f5e933645f7ba871cf50a69dc735365ab
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/src/stdplus/exception.hpp b/src/stdplus/exception.hpp
index 409b0b5..22d9572 100644
--- a/src/stdplus/exception.hpp
+++ b/src/stdplus/exception.hpp
@@ -54,5 +54,24 @@
         };
 }
 
+template <typename F>
+auto ignoreQuiet(F&& f) noexcept
+{
+    return [f = std::move(f)](auto&&... args) mutable noexcept {
+        try
+        {
+            return f(std::forward<decltype(args)>(args)...);
+        }
+        catch (...)
+        {
+        }
+        using Ret = std::invoke_result_t<decltype(f), decltype(args)...>;
+        if constexpr (!std::is_same_v<void, Ret>)
+        {
+            return Ret();
+        }
+    };
+}
+
 } // namespace exception
 } // namespace stdplus
diff --git a/test/exception.cpp b/test/exception.cpp
index 6b4a26f..5d22071 100644
--- a/test/exception.cpp
+++ b/test/exception.cpp
@@ -19,5 +19,11 @@
                      std::move(y)));
 }
 
+TEST(Exception, IgnoreQuiet)
+{
+    ignoreQuiet([] {})();
+    ignoreQuiet([]() mutable { throw std::runtime_error("Boom"); })();
+}
+
 } // namespace exception
 } // namespace stdplus