• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

libbitcoin / libbitcoin-system / 9824402874

07 Jul 2024 03:52AM UTC coverage: 82.558% (-0.2%) from 82.725%
9824402874

Pull #1492

github

web-flow
Merge 826e50a22 into 3046b831f
Pull Request #1492: Add polymorphic allocating byte_reader methods.

53 of 78 new or added lines in 15 files covered. (67.95%)

12 existing lines in 1 file now uncovered.

9864 of 11948 relevant lines covered (82.56%)

4773499.46 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

85.71
/include/bitcoin/system/impl/data/memory.ipp
1
/**
2
 * Copyright (c) 2011-2023 libbitcoin developers (see AUTHORS)
3
 *
4
 * This file is part of libbitcoin.
5
 *
6
 * This program is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU Affero General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU Affero General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU Affero General Public License
17
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
 */
19
#ifndef LIBBITCOIN_SYSTEM_DATA_MEMORY_IPP
20
#define LIBBITCOIN_SYSTEM_DATA_MEMORY_IPP
21

22
#include <algorithm>
23
#include <memory>
24
#include <memory_resource>
25
#include <utility>
26
#include <vector>
27
#include <bitcoin/system/define.hpp>
28

29
namespace libbitcoin {
30
namespace system {
31

32
BC_PUSH_WARNING(NO_THROW_IN_NOEXCEPT)
33

34
// Create shared pointer to vector of const shared ptr from the moved vector.
35
template <typename Type>
36
std::shared_ptr<std_vector<std::shared_ptr<const Type>>>
37
to_shareds(std_vector<Type>&& values) NOEXCEPT
1,651✔
38
{
39
    const auto out = std::make_shared<std_vector<std::shared_ptr<
1,651✔
40
        const Type>>>(values.size());
1,651✔
41

42
    std::transform(values.begin(), values.end(), out->begin(),
1,651✔
43
        [](Type& value) NOEXCEPT
892✔
44
        {
45
            return to_shared(std::move(value));
46
        });
47

48
    return out;
1,651✔
49
}
50

51
// Create shared pointer to vector of const shared ptr from the copied vector.
52
template <typename Type>
53
std::shared_ptr<std_vector<std::shared_ptr<const Type>>> to_shareds(
32✔
54
    const std_vector<Type>& values) NOEXCEPT
55
{
56
    const auto out = std::make_shared<std_vector<std::shared_ptr<
32✔
57
        const Type>>>(values.size());
32✔
58

59
    std::transform(values.begin(), values.end(), out->begin(),
32✔
60
        [](const Type& value) NOEXCEPT
103✔
61
        {
62
            return to_shared(value);
63
        });
64

65
    return out;
32✔
66
}
67

68
// Allocate a shared instance and construct with given arguments.
69
template <typename Type, typename Allocator, typename ...Args>
NEW
70
std::shared_ptr<const Type> to_allocated(const Allocator& allocator,
×
71
    Args&&... args) NOEXCEPT
72
{
73
    return std::allocate_shared<const Type,
74
        std::pmr::polymorphic_allocator<const Type>>(allocator,
NEW
75
            std::forward<Args>(args)...);
×
76
}
77

78
BC_POP_WARNING()
79

80
} // namespace system
81
} // namespace libbitcoin
82

83
#endif
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc