GCC Code Coverage Report


Directory: include/kumi/
File: include/kumi/utils/unit_type.hpp
Date: 2026-10-14 16:33:56
Exec Total Coverage
Lines: 3 3 100.0%
Functions: 1 1 100.0%
Branches: 0 0 -%

Line Branch Exec Source
1 //======================================================================================================================
2 /*
3 KUMI - Compact Tuple Tools
4 Copyright : KUMI Project Contributors
5 SPDX-License-Identifier: BSL-1.0
6 */
7 //======================================================================================================================
8 #pragma once
9
10 namespace kumi
11 {
12 //====================================================================================================================
13 /**
14 @ingroup kumi_types
15 @class unit
16 @brief A type representing the product of no type, also called the unit type
17
18 kumi::unit provides a way to define the unit type in a constexpr friendly manner.
19 @see @ref kumi_unit
20 **/
21 //====================================================================================================================
22 struct unit
23 {
24 6 KUMI_ABI friend constexpr auto operator<=>(unit, unit) noexcept = default;
25
26 template<typename T>
27 [[nodiscard]] KUMI_ABI constexpr operator T() const noexcept
28 requires(kumi::concepts::unit_type<T>)
29 {
30 return {};
31 }
32
33 template<typename T>
34 [[nodiscard]] KUMI_ABI constexpr operator T() noexcept
35 requires(kumi::concepts::unit_type<T>)
36 {
37 return {};
38 }
39
40 template<typename CharT, typename Traits>
41 5 friend std::basic_ostream<CharT, Traits>& operator<<(std::basic_ostream<CharT, Traits>& os, unit) noexcept
42 {
43 5 return os << '\'' << "none" << '\'';
44 }
45 };
46
47 //====================================================================================================================
48 /**
49 @ingroup kumi_utility
50 @brief Inline constant representing a kumi::unit.
51 **/
52 //====================================================================================================================
53 inline constexpr kumi::unit none{};
54 }
55