diff options
author | Caolán McNamara <caolanm@redhat.com> | 2020-06-27 16:47:49 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2020-06-27 21:47:11 +0200 |
commit | d1069a583dc1bcf4f1cf9b4bed12cb48bc757951 (patch) | |
tree | bd4716714a9a67bc0e9d0c8808904c6162f3989a /include/o3tl | |
parent | 22bacc8205e2a1ee5134dbbddbb75414ab5d12af (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.hxx | 15 |
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 |