GCC Code Coverage Report


Directory: include/polyfloat/
File: include/polyfloat/module/core/is_odd.hpp
Date: 2026-11-09 15:28:50
Exec Total Coverage
Lines: 6 6 100.0%
Functions: 49 49 100.0%
Branches: 0 0 -%

Line Branch Exec Source
1 //======================================================================================================================
2 /*
3 POLYFLOAT - Extended precision floating points
4 Copyright : POLYFLOAT Contributors & Maintainers
5 SPDX-License-Identifier: BSL-1.0
6 */
7 //======================================================================================================================
8 #pragma once
9
10 #include <polyfloat/details/callable.hpp>
11 #include <polyfloat/types/concepts.hpp>
12 #include <polyfloat/types/traits.hpp>
13 #include <type_traits>
14 #include <polyfloat/module/core/is_flint.hpp>
15
16 namespace plf
17 {
18
19 template<typename Options> struct is_odd_t : eve::elementwise_callable<is_odd_t, Options, raw_option, pedantic_option>
20 {
21 template<concepts::polyfloat_like Z>
22 96855 POLYFLOAT_ABI constexpr eve::as_logical_t<plf::as_component_type_t<Z>> operator()(Z z) const noexcept
23 {
24 96855 return POLYFLOAT_CALL(z);
25 }
26
27 96815 POLYFLOAT_CALLABLE_OBJECT(is_odd_t, is_odd_);
28 };
29
30 //================================================================================================
31 //! @addtogroup core
32 //! @{
33 //! @var is_odd
34 //! @brief `elementwise callable`returns a logical true if and only if the element value is a floating value
35 //! representing an odd integer
36 //!
37 //! @groupheader{Header file}
38 //!
39 //! @code
40 //! #include <eve/module/module/core.hpp>
41 //! @endcode
42 //!
43 //! @groupheader{Callable Signatures}
44 //!
45 //! @code
46 //! namespace plf
47 //! {
48 //! // Regular overloads
49 //! constexpr auto is_odd(floating_value auto x) noexcept;
50 //! }
51 //! @endcode
52 //!
53 //! **Parameters**
54 //!
55 //! * `x`: [argument](@ref eve::value).
56 //!
57 //! **Return value**
58 //!
59 //! 1. returns true if and only if x represent an odd number
60 //!
61 //! @groupheader{Example}
62 //! @godbolt{doc/core/is_odd.cpp}
63 //================================================================================================
64 inline constexpr auto is_odd = eve::functor<is_odd_t>;
65 //======================================================================================================================
66 //! @}
67 //======================================================================================================================
68 }
69
70 namespace plf::_
71 {
72 96815 template<typename Z, eve::callable_options O> constexpr auto is_odd_(POLYFLOAT_DELAY(), O const&, Z const& a) noexcept
73 {
74 96815 auto da = dec(a);
75 96815 return (a != da) && is_even(da);
76 }
77 }
78