GCC Code Coverage Report


Directory: ./
File: PointerMap.hpp
Date: 2026-03-21 20:51:59
Exec Total Coverage
Lines: 5 6 83.3%
Functions: 1 1 100.0%
Branches: 7 12 58.3%

Line Branch Exec Source
1 #pragma once
2
3 #include "IndirectMap.hpp"
4 #include <map>
5 #include <memory>
6
7 template <typename Key, typename P>
8 using PointerMap = IndirectMap<std::map<Key, P>>;
9
10 template <typename Key, typename T>
11 using RawPointerMap = PointerMap<Key, T*>;
12
13 template <typename Key, typename T>
14 using UniquePointerMap = PointerMap<Key, std::unique_ptr<T>>;
15
16 template <typename Key, typename T>
17 using SharedPointerMap = PointerMap<Key, std::shared_ptr<T>>;
18
19 template <typename M>
20 5 RawPointerMap<typename M::key_type, typename M::mapped_type> reference(
21 [[maybe_unused]] M& map) {
22 5 auto result = RawPointerMap<typename M::key_type, typename M::mapped_type>{};
23
6/10
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 8 taken 14 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 14 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 19 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 14 times.
✓ Branch 17 taken 5 times.
33 for (auto&& element : map) {
24
1/2
✓ Branch 8 taken 14 times.
✗ Branch 9 not taken.
14 result.base.emplace(element.first, &element.second);
25 }
26 5 return result;
27 }
28
29 template <typename M>
30 const RawPointerMap<typename M::key_type, typename M::mapped_type> reference(
31 const M& map) {
32 return const_cast<const RawPointerMap<typename M::key_type, typename M::mapped_type>>(
33 reference(const_cast<M&>(map))); // NOLINT(*-const-cast)
34 }
35