1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 #ifndef INCLUDED_O3TL_MAKE_SHARED_HXX
11 #define INCLUDED_O3TL_MAKE_SHARED_HXX
14 #include <type_traits>
18 /** Allocate an array stored in a shared_ptr, calling operator delete[].
19 Note that this is only allowed for arithmetic types because shared_ptr
20 implicitly converts to sub-types.
23 std::shared_ptr
<T
> make_shared_array(size_t const size
)
25 static_assert(std::is_arithmetic
<T
>::value
, "only arrays of arithmetic types allowed");
26 return std::shared_ptr
<T
>(new T
[size
], std::default_delete
<T
[]>());
31 #endif // INCLUDED_O3TL_MAKE_SHARED_HXX
33 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */