/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #ifndef INCLUDED_O3TL_MAKE_SHARED_HXX #define INCLUDED_O3TL_MAKE_SHARED_HXX #include #include #include namespace o3tl { /** Allocate an array stored in a shared_ptr, calling operator delete[]. Note that this is only allowed for arithmetic types because shared_ptr implicitly converts to sub-types. */ template std::shared_ptr make_shared_array(size_t const size) { static_assert(std::is_arithmetic::value, "only arrays of arithmetic types allowed"); return std::shared_ptr(new T[size], std::default_delete()); } /** 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 std::shared_ptr make_shared(Args&&... args) { #if defined(__COVERITY__) return std::shared_ptr(new T(std::forward(args)...), o3tl::default_delete()); #else return std::make_shared(std::forward(args)...); #endif } } // namespace o3tl #endif // INCLUDED_O3TL_MAKE_SHARED_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ ffice-5-3'>distro/cib/libreoffice-5-3 LibreOffice 核心代码仓库文档基金会
summaryrefslogtreecommitdiff
AgeCommit message (Expand)Author
2021-06-18loplugin:finalclasses in swNoel Grandin
2019-12-12use covariant return type for SfxPoolItem::CloneCaolán McNamara
2019-02-28use the xmlTextWriterPtr typedef consistentlyNoel Grandin
2018-11-16entirity of writer rebuilding when vcl widget headers changeCaolán McNamara