GCC Code Coverage Report


Directory: libs/beast2/
File: include/boost/beast2/detail/type_info.hpp
Date: 2025-11-13 15:50:44
Exec Total Coverage
Lines: 2 2 100.0%
Functions: 0 1 0.0%
Branches: 0 0 -%

Line Branch Exec Source
1 //
2 // Copyright (c) 2025 Vinnie Falco (vinnie dot falco at gmail dot com)
3 //
4 // Distributed under the Boost Software License, Version 1.0. (See accompanying
5 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 //
7 // Official repository: https://github.com/cppalliance/beast2
8 //
9
10 #ifndef BOOST_BEAST2_DETAIL_TYPE_INFO_HPP
11 #define BOOST_BEAST2_DETAIL_TYPE_INFO_HPP
12
13 #ifndef BOOST_NO_RTTI
14 # include <typeinfo>
15 #else
16 # include <cstdint>
17 #endif
18
19 namespace boost {
20 namespace beast2 {
21 namespace detail {
22
23 #ifdef BOOST_NO_RTTI
24
25 struct type_info
26 {
27 std::size_t hash_code() const noexcept
28 {
29 return reinterpret_cast<std::uintptr_t>(this);
30 }
31
32 friend bool operator==(type_info const& lhs,
33 type_info const& rhs) noexcept
34 {
35 return &lhs == &rhs;
36 }
37
38 friend bool operator!=(type_info const& lhs,
39 type_info const& rhs) noexcept
40 {
41 return &lhs != &rhs;
42 }
43 };
44
45 template<class T>
46 struct type_info_for
47 {
48 static type_info const value;
49 };
50
51 template<class T>
52 type_info const type_info_for<T>::value{};
53
54 template<class T>
55 type_info const& get_type_info() noexcept
56 {
57 return type_info_for<T>::value;
58 }
59
60 #else
61
62 using type_info = std::type_info;
63
64 template<class T>
65 type_info const&
66 84 get_type_info() noexcept
67 {
68 84 return typeid(T);
69 }
70
71 #endif
72
73 } // detail
74 } // beast2
75 } // boost
76
77 #endif
78