summaryrefslogtreecommitdiff
path: root/include/o3tl
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2020-06-27 16:47:49 +0100
committerCaolán McNamara <caolanm@redhat.com>2020-06-27 21:47:11 +0200
commitd1069a583dc1bcf4f1cf9b4bed12cb48bc757951 (patch)
treebd4716714a9a67bc0e9d0c8808904c6162f3989a /include/o3tl
parent22bacc8205e2a1ee5134dbbddbb75414ab5d12af (diff)
cid#1401342 Uncaught exception
Change-Id: Ia22ed8541f1148355d71cd5b90ad13e64c1b50c2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97289 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'include/o3tl')
-rw-r--r--include/o3tl/make_shared.hxx15
1 files changed, 15 insertions, 0 deletions
diff --git a/include/o3tl/make_shared.hxx b/include/o3tl/make_shared.hxx
index d42783c301fa..9d7998fd5a36 100644
--- a/include/o3tl/make_shared.hxx
+++ b/include/o3tl/make_shared.hxx
@@ -10,6 +10,7 @@
#ifndef INCLUDED_O3TL_MAKE_SHARED_HXX
#define INCLUDED_O3TL_MAKE_SHARED_HXX
+#include <o3tl/deleter.hxx>
#include <memory>
#include <type_traits>
@@ -26,6 +27,20 @@ std::shared_ptr<T> make_shared_array(size_t const size)
return std::shared_ptr<T>(new T[size], std::default_delete<T[]>());
}
+/** To markup std::shared_ptr that coverity warns might throw exceptions
+ which won't throw in practice, or where std::terminate is
+ an acceptable response if they do
+*/
+template<class T, class... Args>
+std::shared_ptr<T> make_shared(Args&&... args)
+{
+#if defined(__COVERITY__)
+ return std::shared_ptr<T>(new T(std::forward<Args>(args)...), o3tl::default_delete<T>());
+#else
+ return std::make_shared<T>(std::forward<Args>(args)...);
+#endif
+}
+
} // namespace o3tl
#endif // INCLUDED_O3TL_MAKE_SHARED_HXX