Coverage Report

Created: 2026-03-31 11:00

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/include/o3tl/make_shared.hxx
Line
Count
Source
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/*
3
 * This file is part of the LibreOffice project.
4
 *
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/.
8
 */
9
10
#ifndef INCLUDED_O3TL_MAKE_SHARED_HXX
11
#define INCLUDED_O3TL_MAKE_SHARED_HXX
12
13
#include <memory>
14
#include <type_traits>
15
16
namespace o3tl
17
{
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.
21
 */
22
template <typename T> std::shared_ptr<T> make_shared_array(size_t const size)
23
16.0k
{
24
16.0k
    static_assert(std::is_arithmetic<T>::value, "only arrays of arithmetic types allowed");
25
16.0k
    return std::shared_ptr<T>(new T[size], std::default_delete<T[]>());
26
16.0k
}
27
28
} // namespace o3tl
29
30
#endif // INCLUDED_O3TL_MAKE_SHARED_HXX
31
32
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */