GCC Code Coverage Report


Directory: include/polyfloat/
File: include/polyfloat/details/callable.hpp
Date: 2026-11-09 15:28:50
Exec Total Coverage
Lines: 6 6 100.0%
Functions: 1733 1801 96.2%
Branches: 4 4 100.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 #include <polyfloat/details/abi.hpp>
10 #include <polyfloat/types/traits.hpp>
11 #include <eve/traits/overload.hpp>
12
13 namespace plf::_
14 {
15 EVE_CALLABLE_NAMESPACE();
16 }
17
18 // EVE-related macro that use polyfloat::_ as the deferred namespace
19 #define POLYFLOAT_CALLABLE_OBJECT(TYPE, NAME) EVE_CALLABLE_OBJECT_FROM(plf::_, TYPE, NAME)
20 #define POLYFLOAT_CALL(...) EVE_DISPATCH_CALL(__VA_ARGS__)
21 #define POLYFLOAT_DELAY() EVE_REQUIRES(eve::cpu_)
22
23 namespace plf
24 {
25 namespace _
26 {
27 // behavior() is the entry point eve dispatches every call through
28 template<template<typename> class Eve, typename Base> struct deferring_callable : Base
29 {
30 template<eve::callable_options O, typename... Ts>
31 5269498 constexpr auto behavior(auto arch, O const& opts, Ts... xs) const
32 {
33
2/2
✓ Branch 1 taken 200190 times.
✓ Branch 4 taken 21865 times.
400380 if constexpr (((dimension_v<Ts> == 1) && ...)) return eve::functor<Eve>[opts](xs...);
34 4869118 else return Base::behavior(arch, opts, xs...);
35 }
36 };
37
38 template<template<typename> class Eve, typename Base> struct deferring_constant : Base
39 {
40 154577 template<typename O, typename T> constexpr auto behavior(auto arch, O const& opts, eve::as<T> target) const
41 {
42
2/2
✓ Branch 1 taken 116 times.
✓ Branch 4 taken 116 times.
232 if constexpr (dimension_v<T> == 1) return eve::functor<Eve>[opts](target);
43 154345 else return Base::behavior(arch, opts, target);
44 }
45 };
46 }
47
48 //====================================================================================================================
49 //! @addtogroup traits
50 //! @{
51 //====================================================================================================================
52
53 //====================================================================================================================
54 //! @struct elementwise_callable
55 //! @brief [polyfloat](@ref plf) counterpart of eve::elementwise_callable.
56 //!
57 //! Behaves as eve::elementwise_callable except when all its parameters have a dimension_v equal to 1, in which case
58 //! it forwards to [EVE](https://jfalcou.github.io/eve/) directly.
59 //!
60 //! @tparam Func The callable being defined
61 //! @tparam Eve The [EVE](https://jfalcou.github.io/eve/) callable to forward to
62 //! @tparam OptionsValues Type of the stored options
63 //! @tparam Options List of supported option specifications
64 //====================================================================================================================
65 template<template<typename> class Func, template<typename> class Eve, typename OptionsValues, typename... Options>
66 struct elementwise_callable : _::deferring_callable<Eve, eve::elementwise_callable<Func, OptionsValues, Options...>>
67 {
68 };
69
70 //====================================================================================================================
71 //! @struct strict_tuple_callable
72 //! @brief [polyfloat](@ref plf) counterpart of eve::strict_tuple_callable.
73 //!
74 //! Behaves as eve::strict_tuple_callable except when all its parameters have a dimension_v equal to 1, in which case
75 //! it forwards to [EVE](https://jfalcou.github.io/eve/) directly.
76 //!
77 //! @tparam Func The callable being defined
78 //! @tparam Eve The [EVE](https://jfalcou.github.io/eve/) callable to forward to
79 //! @tparam OptionsValues Type of the stored options
80 //! @tparam Options List of supported option specifications
81 //====================================================================================================================
82 template<template<typename> class Func, template<typename> class Eve, typename OptionsValues, typename... Options>
83 struct strict_tuple_callable : _::deferring_callable<Eve, eve::strict_tuple_callable<Func, OptionsValues, Options...>>
84 {
85 };
86
87 //====================================================================================================================
88 //! @struct callable
89 //! @brief [polyfloat](@ref plf) counterpart of eve::callable.
90 //!
91 //! Behaves as eve::callable except when all its parameters have a dimension_v equal to 1, in which case it forwards
92 //! to [EVE](https://jfalcou.github.io/eve/) directly.
93 //!
94 //! @tparam Func The callable being defined
95 //! @tparam Eve The [EVE](https://jfalcou.github.io/eve/) callable to forward to
96 //! @tparam OptionsValues Type of the stored options
97 //! @tparam Options List of supported option specifications
98 //====================================================================================================================
99 template<template<typename> class Func, template<typename> class Eve, typename OptionsValues, typename... Options>
100 struct callable : _::deferring_callable<Eve, eve::callable<Func, OptionsValues, Options...>>
101 {
102 };
103
104 //====================================================================================================================
105 //! @struct constant_callable
106 //! @brief [polyfloat](@ref plf) counterpart of eve::constant_callable.
107 //!
108 //! Behaves as eve::constant_callable except when its target type has a dimension_v equal to 1, in which case it
109 //! forwards to [EVE](https://jfalcou.github.io/eve/) directly.
110 //!
111 //! @tparam Func The constant being defined
112 //! @tparam Eve The [EVE](https://jfalcou.github.io/eve/) constant to forward to
113 //! @tparam OptionsValues Type of the stored options
114 //! @tparam Options List of supported option specifications
115 //====================================================================================================================
116 template<template<typename> class Func, template<typename> class Eve, typename OptionsValues, typename... Options>
117 struct constant_callable : _::deferring_constant<Eve, eve::constant_callable<Func, OptionsValues, Options...>>
118 {
119 };
120
121 //====================================================================================================================
122 //! @}
123 //====================================================================================================================
124 }
125