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

STEllAR-GROUP / hpx / #854

18 Dec 2022 11:19PM UTC coverage: 86.511% (+0.2%) from 86.287%
#854

push

StellarBot
Merge #6111

6111: Modernize all modules from module level 8 r=hkaiser a=hkaiser

modules: datastructures, hashing, memory, checkpointing_base

- flyby: adding `hpx::construct_at`

working towards https://github.com/STEllAR-GROUP/hpx/issues/5497

Co-authored-by: Hartmut Kaiser <hartmut.kaiser@gmail.com>

127 of 127 new or added lines in 33 files covered. (100.0%)

174410 of 201605 relevant lines covered (86.51%)

1917096.95 hits per line

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

51.85
/libs/core/datastructures/src/serializable_any.cpp
1
/*=============================================================================
2
    Copyright (c) 2013 Shuangyang Yang
3
    Copyright (c) 2007-2022 Hartmut Kaiser
4
    Copyright (c) Christopher Diggins 2005
5
    Copyright (c) Pablo Aguilar 2005
6
    Copyright (c) Kevlin Henney 2001
7

8
//  SPDX-License-Identifier: BSL-1.0
9
    Distributed under the Boost Software License, Version 1.0. (See accompanying
10
    file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
11

12
    The class hpx::any is built based on boost::spirit::hold_any class. It adds
13
    support for HPX serialization, move assignment, == operator.
14
==============================================================================*/
15

16
#include <hpx/config.hpp>
17
#include <hpx/datastructures/serialization/serializable_any.hpp>
18
#include <hpx/serialization/serialize.hpp>
19

20
#include <boost/functional/hash.hpp>
21

22
#include <cstddef>
23
#include <type_traits>
24
#include <vector>
25

26
////////////////////////////////////////////////////////////////////////////////
27
namespace hpx::util {
28

29
    ////////////////////////////////////////////////////////////////////////////
30
    namespace detail {
31

32
        struct hash_binary_filter : serialization::binary_filter
13✔
33
        {
34
            explicit constexpr hash_binary_filter(std::size_t seed = 0) noexcept
13✔
35
              : hash(seed)
13✔
36
            {
26✔
37
            }
13✔
38

39
            // compression API
40
            void set_max_length(std::size_t /* size */) override {}
×
41
            void save(void const* src, std::size_t src_count) override
×
42
            {
43
                char const* data = static_cast<char const*>(src);
×
44
                boost::hash_range(hash, data, data + src_count);
×
45
            }
×
46
            bool flush(void* /* dst */, std::size_t dst_count,
×
47
                std::size_t& written) override
48
            {
49
                written = dst_count;
×
50
                return true;
×
51
            }
52

53
            // decompression API
54
            std::size_t init_data(void const* /* buffer */,
×
55
                std::size_t /* size */, std::size_t /* buffer_size */) override
56
            {
57
                return 0;
×
58
            }
59
            void load(void* /* dst */, std::size_t /* dst_count */) override {}
×
60

61
            template <class T>
62
            constexpr void serialize(T&, unsigned) noexcept
×
63
            {
64
            }
×
65
            HPX_SERIALIZATION_POLYMORPHIC(hash_binary_filter, override);
1,251✔
66

67
            std::size_t hash;
68
        };
69
    }    // namespace detail
70

71
    ////////////////////////////////////////////////////////////////////////////
72
    template <typename Char>
73
    std::size_t hash_any::operator()(basic_any<serialization::input_archive,
13✔
74
        serialization::output_archive, Char, std::true_type> const& elem) const
75
    {
76
        detail::hash_binary_filter hasher;
13✔
77

78
        {
79
            std::vector<char> data;
13✔
80
            serialization::output_archive ar(data, 0U, nullptr, &hasher);
13✔
81
            ar << elem;
13✔
82
        }    // let archive go out of scope
13✔
83

84
        return hasher.hash;
13✔
85
    }
13✔
86

87
    template HPX_CORE_EXPORT std::size_t hash_any::operator()(
88
        basic_any<serialization::input_archive, serialization::output_archive,
89
            char, std::true_type> const& elem) const;
90

91
    template HPX_CORE_EXPORT std::size_t hash_any::operator()(
92
        basic_any<serialization::input_archive, serialization::output_archive,
93
            wchar_t, std::true_type> const& elem) const;
94
}    // namespace hpx::util
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