/src/libreoffice/include/o3tl/safeint.hxx
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* |
3 | | * This file is part of the LibreOffice project. |
4 | | * |
5 | | * This Source Code Form is subject to the terms of the Mozilla Public |
6 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
7 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
8 | | */ |
9 | | |
10 | | #pragma once |
11 | | |
12 | | #include <sal/config.h> |
13 | | |
14 | | #include <algorithm> |
15 | | #include <cassert> |
16 | | #include <limits> |
17 | | #include <type_traits> |
18 | | |
19 | | #if defined(_MSC_VER) |
20 | | #include <safeint.h> |
21 | | #else |
22 | | #ifndef __has_builtin |
23 | | # define __has_builtin(x) 0 |
24 | | #endif |
25 | | #endif |
26 | | |
27 | | namespace o3tl |
28 | | { |
29 | | |
30 | | template <typename T> inline constexpr T saturating_add(T a, T b) |
31 | 140M | { |
32 | 140M | if (b >= 0) { |
33 | 138M | if (a <= std::numeric_limits<T>::max() - b) { |
34 | 138M | return a + b; |
35 | 138M | } else { |
36 | 28.7k | return std::numeric_limits<T>::max(); |
37 | 28.7k | } |
38 | 138M | } else { |
39 | | // coverity[dead_error_line] - suppress warning for template |
40 | 1.76M | if (a >= std::numeric_limits<T>::min() - b) { |
41 | 1.75M | return a + b; |
42 | 1.75M | } else { |
43 | 9.83k | return std::numeric_limits<T>::min(); |
44 | 9.83k | } |
45 | 1.76M | } |
46 | 140M | } Unexecuted instantiation: unsigned long o3tl::saturating_add<unsigned long>(unsigned long, unsigned long) long o3tl::saturating_add<long>(long, long) Line | Count | Source | 31 | 395k | { | 32 | 395k | if (b >= 0) { | 33 | 370k | if (a <= std::numeric_limits<T>::max() - b) { | 34 | 369k | return a + b; | 35 | 369k | } else { | 36 | 1.72k | return std::numeric_limits<T>::max(); | 37 | 1.72k | } | 38 | 370k | } else { | 39 | | // coverity[dead_error_line] - suppress warning for template | 40 | 24.3k | if (a >= std::numeric_limits<T>::min() - b) { | 41 | 23.7k | return a + b; | 42 | 23.7k | } else { | 43 | 603 | return std::numeric_limits<T>::min(); | 44 | 603 | } | 45 | 24.3k | } | 46 | 395k | } |
int o3tl::saturating_add<int>(int, int) Line | Count | Source | 31 | 139M | { | 32 | 139M | if (b >= 0) { | 33 | 137M | if (a <= std::numeric_limits<T>::max() - b) { | 34 | 137M | return a + b; | 35 | 137M | } else { | 36 | 26.4k | return std::numeric_limits<T>::max(); | 37 | 26.4k | } | 38 | 137M | } else { | 39 | | // coverity[dead_error_line] - suppress warning for template | 40 | 1.74M | if (a >= std::numeric_limits<T>::min() - b) { | 41 | 1.73M | return a + b; | 42 | 1.73M | } else { | 43 | 9.13k | return std::numeric_limits<T>::min(); | 44 | 9.13k | } | 45 | 1.74M | } | 46 | 139M | } |
short o3tl::saturating_add<short>(short, short) Line | Count | Source | 31 | 638k | { | 32 | 638k | if (b >= 0) { | 33 | 638k | if (a <= std::numeric_limits<T>::max() - b) { | 34 | 638k | return a + b; | 35 | 638k | } else { | 36 | 485 | return std::numeric_limits<T>::max(); | 37 | 485 | } | 38 | 638k | } else { | 39 | | // coverity[dead_error_line] - suppress warning for template | 40 | 95 | if (a >= std::numeric_limits<T>::min() - b) { | 41 | 0 | return a + b; | 42 | 95 | } else { | 43 | 95 | return std::numeric_limits<T>::min(); | 44 | 95 | } | 45 | 95 | } | 46 | 638k | } |
|
47 | | |
48 | | template <typename T> inline constexpr T saturating_sub(T a, T b) |
49 | 1.72M | { |
50 | 1.72M | if (b >= 0) { |
51 | 1.39M | if (a >= std::numeric_limits<T>::min() + b) { |
52 | 1.39M | return a - b; |
53 | 1.39M | } else { |
54 | 1.07k | return std::numeric_limits<T>::min(); |
55 | 1.07k | } |
56 | 1.39M | } else { |
57 | 325k | if (a <= std::numeric_limits<T>::max() + b) { |
58 | 323k | return a - b; |
59 | 323k | } else { |
60 | 2.42k | return std::numeric_limits<T>::max(); |
61 | 2.42k | } |
62 | 325k | } |
63 | 1.72M | } long o3tl::saturating_sub<long>(long, long) Line | Count | Source | 49 | 403k | { | 50 | 403k | if (b >= 0) { | 51 | 79.8k | if (a >= std::numeric_limits<T>::min() + b) { | 52 | 78.8k | return a - b; | 53 | 78.8k | } else { | 54 | 935 | return std::numeric_limits<T>::min(); | 55 | 935 | } | 56 | 323k | } else { | 57 | 323k | if (a <= std::numeric_limits<T>::max() + b) { | 58 | 320k | return a - b; | 59 | 320k | } else { | 60 | 2.41k | return std::numeric_limits<T>::max(); | 61 | 2.41k | } | 62 | 323k | } | 63 | 403k | } |
short o3tl::saturating_sub<short>(short, short) Line | Count | Source | 49 | 638k | { | 50 | 638k | if (b >= 0) { | 51 | 638k | if (a >= std::numeric_limits<T>::min() + b) { | 52 | 638k | return a - b; | 53 | 638k | } else { | 54 | 95 | return std::numeric_limits<T>::min(); | 55 | 95 | } | 56 | 638k | } else { | 57 | 0 | if (a <= std::numeric_limits<T>::max() + b) { | 58 | 0 | return a - b; | 59 | 0 | } else { | 60 | 0 | return std::numeric_limits<T>::max(); | 61 | 0 | } | 62 | 0 | } | 63 | 638k | } |
int o3tl::saturating_sub<int>(int, int) Line | Count | Source | 49 | 679k | { | 50 | 679k | if (b >= 0) { | 51 | 676k | if (a >= std::numeric_limits<T>::min() + b) { | 52 | 676k | return a - b; | 53 | 676k | } else { | 54 | 44 | return std::numeric_limits<T>::min(); | 55 | 44 | } | 56 | 676k | } else { | 57 | 2.37k | if (a <= std::numeric_limits<T>::max() + b) { | 58 | 2.36k | return a - b; | 59 | 2.36k | } else { | 60 | 10 | return std::numeric_limits<T>::max(); | 61 | 10 | } | 62 | 2.37k | } | 63 | 679k | } |
|
64 | | |
65 | | template<typename T> inline |
66 | | typename std::enable_if<std::is_signed<T>::value, T>::type saturating_toggle_sign( |
67 | | T a) |
68 | 25.2k | { |
69 | 25.2k | if (a == std::numeric_limits<T>::min()) |
70 | 5.69k | return std::numeric_limits<T>::max(); |
71 | 19.5k | return a * -1; |
72 | 25.2k | } _ZN4o3tl22saturating_toggle_signIiEENSt3__19enable_ifIXsr3std9is_signedIT_EE5valueES3_E4typeES3_ Line | Count | Source | 68 | 23.8k | { | 69 | 23.8k | if (a == std::numeric_limits<T>::min()) | 70 | 5.48k | return std::numeric_limits<T>::max(); | 71 | 18.3k | return a * -1; | 72 | 23.8k | } |
_ZN4o3tl22saturating_toggle_signIlEENSt3__19enable_ifIXsr3std9is_signedIT_EE5valueES3_E4typeES3_ Line | Count | Source | 68 | 1.32k | { | 69 | 1.32k | if (a == std::numeric_limits<T>::min()) | 70 | 209 | return std::numeric_limits<T>::max(); | 71 | 1.11k | return a * -1; | 72 | 1.32k | } |
|
73 | | |
74 | | // TODO: reimplement using ckd_add/ckd_sub/ckd_mul from <stdckdint.h>, when C23 is part of C++ |
75 | | |
76 | | #if defined(_MSC_VER) |
77 | | |
78 | | template<typename T> inline bool checked_multiply(T a, T b, T& result) |
79 | | { |
80 | | return !msl::utilities::SafeMultiply(a, b, result); |
81 | | } |
82 | | |
83 | | template<typename T> inline bool checked_add(T a, T b, T& result) |
84 | | { |
85 | | return !msl::utilities::SafeAdd(a, b, result); |
86 | | } |
87 | | |
88 | | template<typename T> inline bool checked_sub(T a, T b, T& result) |
89 | | { |
90 | | return !msl::utilities::SafeSubtract(a, b, result); |
91 | | } |
92 | | |
93 | | #elif (defined __GNUC__ && !defined __clang__) || (__has_builtin(__builtin_mul_overflow) && !(defined(__clang__) && (defined(ANDROID) || defined(__arm__) || defined(__i386__)))) |
94 | | // 32-bit clang fails with undefined reference to `__mulodi4' |
95 | | |
96 | | template<typename T> inline bool checked_multiply(T a, T b, T& result) |
97 | 77.7M | { |
98 | 77.7M | return __builtin_mul_overflow(a, b, &result); |
99 | 77.7M | } bool o3tl::checked_multiply<int>(int, int, int&) Line | Count | Source | 97 | 72.7M | { | 98 | 72.7M | return __builtin_mul_overflow(a, b, &result); | 99 | 72.7M | } |
bool o3tl::checked_multiply<long>(long, long, long&) Line | Count | Source | 97 | 2.65M | { | 98 | 2.65M | return __builtin_mul_overflow(a, b, &result); | 99 | 2.65M | } |
bool o3tl::checked_multiply<unsigned int>(unsigned int, unsigned int, unsigned int&) Line | Count | Source | 97 | 1.14M | { | 98 | 1.14M | return __builtin_mul_overflow(a, b, &result); | 99 | 1.14M | } |
bool o3tl::checked_multiply<unsigned long>(unsigned long, unsigned long, unsigned long&) Line | Count | Source | 97 | 1.21M | { | 98 | 1.21M | return __builtin_mul_overflow(a, b, &result); | 99 | 1.21M | } |
bool o3tl::checked_multiply<unsigned short>(unsigned short, unsigned short, unsigned short&) Line | Count | Source | 97 | 11.9k | { | 98 | 11.9k | return __builtin_mul_overflow(a, b, &result); | 99 | 11.9k | } |
|
100 | | |
101 | | template<typename T> inline bool checked_add(T a, T b, T& result) |
102 | 327M | { |
103 | 327M | return __builtin_add_overflow(a, b, &result); |
104 | 327M | } bool o3tl::checked_add<long>(long, long, long&) Line | Count | Source | 102 | 805k | { | 103 | 805k | return __builtin_add_overflow(a, b, &result); | 104 | 805k | } |
bool o3tl::checked_add<unsigned int>(unsigned int, unsigned int, unsigned int&) Line | Count | Source | 102 | 564k | { | 103 | 564k | return __builtin_add_overflow(a, b, &result); | 104 | 564k | } |
bool o3tl::checked_add<int>(int, int, int&) Line | Count | Source | 102 | 323M | { | 103 | 323M | return __builtin_add_overflow(a, b, &result); | 104 | 323M | } |
bool o3tl::checked_add<unsigned long>(unsigned long, unsigned long, unsigned long&) Line | Count | Source | 102 | 25.4k | { | 103 | 25.4k | return __builtin_add_overflow(a, b, &result); | 104 | 25.4k | } |
bool o3tl::checked_add<short>(short, short, short&) Line | Count | Source | 102 | 2.18M | { | 103 | 2.18M | return __builtin_add_overflow(a, b, &result); | 104 | 2.18M | } |
bool o3tl::checked_add<unsigned short>(unsigned short, unsigned short, unsigned short&) Line | Count | Source | 102 | 1.00k | { | 103 | 1.00k | return __builtin_add_overflow(a, b, &result); | 104 | 1.00k | } |
|
105 | | |
106 | | template<typename T> inline bool checked_sub(T a, T b, T& result) |
107 | 63.2M | { |
108 | 63.2M | return __builtin_sub_overflow(a, b, &result); |
109 | 63.2M | } bool o3tl::checked_sub<long>(long, long, long&) Line | Count | Source | 107 | 2.86k | { | 108 | 2.86k | return __builtin_sub_overflow(a, b, &result); | 109 | 2.86k | } |
bool o3tl::checked_sub<int>(int, int, int&) Line | Count | Source | 107 | 63.2M | { | 108 | 63.2M | return __builtin_sub_overflow(a, b, &result); | 109 | 63.2M | } |
bool o3tl::checked_sub<unsigned short>(unsigned short, unsigned short, unsigned short&) Line | Count | Source | 107 | 142 | { | 108 | 142 | return __builtin_sub_overflow(a, b, &result); | 109 | 142 | } |
|
110 | | |
111 | | #else |
112 | | |
113 | | //https://www.securecoding.cert.org/confluence/display/c/INT32-C.+Ensure+that+operations+on+signed+integers+do+not+result+in+overflow |
114 | | template<typename T> inline typename std::enable_if<std::is_signed<T>::value, bool>::type checked_multiply(T a, T b, T& result) |
115 | | { |
116 | | if (a > 0) { /* a is positive */ |
117 | | if (b > 0) { /* a and b are positive */ |
118 | | if (a > (std::numeric_limits<T>::max() / b)) { |
119 | | return true; /* Handle error */ |
120 | | } |
121 | | } else { /* a positive, b nonpositive */ |
122 | | if (b < (std::numeric_limits<T>::min() / a)) { |
123 | | return true; /* Handle error */ |
124 | | } |
125 | | } /* a positive, b nonpositive */ |
126 | | } else { /* a is nonpositive */ |
127 | | if (b > 0) { /* a is nonpositive, b is positive */ |
128 | | if (a < (std::numeric_limits<T>::min() / b)) { |
129 | | return true; /* Handle error */ |
130 | | } |
131 | | } else { /* a and b are nonpositive */ |
132 | | if ( (a != 0) && (b < (std::numeric_limits<T>::max() / a))) { |
133 | | return true; /* Handle error */ |
134 | | } |
135 | | } /* End if a and b are nonpositive */ |
136 | | } /* End if a is nonpositive */ |
137 | | |
138 | | result = a * b; |
139 | | |
140 | | return false; |
141 | | } |
142 | | |
143 | | //https://www.securecoding.cert.org/confluence/display/c/INT30-C.+Ensure+that+unsigned+integer+operations+do+not+wrap |
144 | | template<typename T> inline typename std::enable_if<std::is_unsigned<T>::value, bool>::type checked_multiply(T a, T b, T& result) |
145 | | { |
146 | | if (b && a > std::numeric_limits<T>::max() / b) { |
147 | | return true;/* Handle error */ |
148 | | } |
149 | | |
150 | | result = a * b; |
151 | | |
152 | | return false; |
153 | | } |
154 | | |
155 | | //https://www.securecoding.cert.org/confluence/display/c/INT32-C.+Ensure+that+operations+on+signed+integers+do+not+result+in+overflow |
156 | | template<typename T> inline typename std::enable_if<std::is_signed<T>::value, bool>::type checked_add(T a, T b, T& result) |
157 | | { |
158 | | if (((b > 0) && (a > (std::numeric_limits<T>::max() - b))) || |
159 | | ((b < 0) && (a < (std::numeric_limits<T>::min() - b)))) { |
160 | | return true; |
161 | | } |
162 | | |
163 | | result = a + b; |
164 | | |
165 | | return false; |
166 | | } |
167 | | |
168 | | //https://www.securecoding.cert.org/confluence/display/c/INT30-C.+Ensure+that+unsigned+integer+operations+do+not+wrap |
169 | | template<typename T> inline typename std::enable_if<std::is_unsigned<T>::value, bool>::type checked_add(T a, T b, T& result) |
170 | | { |
171 | | if (std::numeric_limits<T>::max() - a < b) { |
172 | | return true;/* Handle error */ |
173 | | } |
174 | | |
175 | | result = a + b; |
176 | | |
177 | | return false; |
178 | | } |
179 | | |
180 | | //https://www.securecoding.cert.org/confluence/display/c/INT32-C.+Ensure+that+operations+on+signed+integers+do+not+result+in+overflow |
181 | | template<typename T> inline typename std::enable_if<std::is_signed<T>::value, bool>::type checked_sub(T a, T b, T& result) |
182 | | { |
183 | | if ((b > 0 && a < std::numeric_limits<T>::min() + b) || |
184 | | (b < 0 && a > std::numeric_limits<T>::max() + b)) { |
185 | | return true; |
186 | | } |
187 | | |
188 | | result = a - b; |
189 | | |
190 | | return false; |
191 | | } |
192 | | |
193 | | //https://www.securecoding.cert.org/confluence/display/c/INT30-C.+Ensure+that+unsigned+integer+operations+do+not+wrap |
194 | | template<typename T> inline typename std::enable_if<std::is_unsigned<T>::value, bool>::type checked_sub(T a, T b, T& result) |
195 | | { |
196 | | if (a < b) { |
197 | | return true; |
198 | | } |
199 | | |
200 | | result = a - b; |
201 | | |
202 | | return false; |
203 | | } |
204 | | |
205 | | #endif |
206 | | |
207 | | template<typename T> constexpr std::enable_if_t<std::is_signed_v<T>, std::make_unsigned_t<T>> |
208 | | make_unsigned(T value) |
209 | 5.84G | { |
210 | 5.84G | assert(value >= 0); |
211 | 5.84G | return value; |
212 | 5.84G | } _ZN4o3tl13make_unsignedIiEENSt3__19enable_ifIXsr3stdE11is_signed_vIT_EEu15__make_unsignedIS3_EE4typeES3_ Line | Count | Source | 209 | 5.28G | { | 210 | | assert(value >= 0); | 211 | 5.28G | return value; | 212 | 5.28G | } |
_ZN4o3tl13make_unsignedIlEENSt3__19enable_ifIXsr3stdE11is_signed_vIT_EEu15__make_unsignedIS3_EE4typeES3_ Line | Count | Source | 209 | 73.4M | { | 210 | | assert(value >= 0); | 211 | 73.4M | return value; | 212 | 73.4M | } |
_ZN4o3tl13make_unsignedIsEENSt3__19enable_ifIXsr3stdE11is_signed_vIT_EEu15__make_unsignedIS3_EE4typeES3_ Line | Count | Source | 209 | 480M | { | 210 | | assert(value >= 0); | 211 | 480M | return value; | 212 | 480M | } |
|
213 | | |
214 | | template<typename T1, typename T2> constexpr std::enable_if_t<std::is_unsigned_v<T1>, T1> |
215 | 22 | clamp_to_unsigned(T2 value) { |
216 | 22 | if constexpr (std::is_unsigned_v<T2>) { |
217 | | // coverity[dead_error_line] - suppress warning for template |
218 | 22 | return value <= std::numeric_limits<T1>::max() ? value : std::numeric_limits<T1>::max(); |
219 | 22 | } else { |
220 | 0 | static_assert(std::is_signed_v<T2>); |
221 | 0 | return value < 0 ? 0 : clamp_to_unsigned<T1>(make_unsigned(value)); |
222 | 0 | } |
223 | 22 | } _ZN4o3tl17clamp_to_unsignedImjEENSt3__19enable_ifIXsr3stdE13is_unsigned_vIT_EES3_E4typeET0_ Line | Count | Source | 215 | 22 | clamp_to_unsigned(T2 value) { | 216 | 22 | if constexpr (std::is_unsigned_v<T2>) { | 217 | | // coverity[dead_error_line] - suppress warning for template | 218 | 22 | return value <= std::numeric_limits<T1>::max() ? value : std::numeric_limits<T1>::max(); | 219 | | } else { | 220 | | static_assert(std::is_signed_v<T2>); | 221 | | return value < 0 ? 0 : clamp_to_unsigned<T1>(make_unsigned(value)); | 222 | | } | 223 | 22 | } |
Unexecuted instantiation: _ZN4o3tl17clamp_to_unsignedImiEENSt3__19enable_ifIXsr3stdE13is_unsigned_vIT_EES3_E4typeET0_ |
224 | | |
225 | | // An implicit conversion from T2 to T1, useful in places where an explicit conversion from T2 to |
226 | | // T1 is needed (e.g., in list initialization, if the implicit conversion would be narrowing) but |
227 | | // tools like -fsanitize=implicit-conversion should still be able to detect truncation: |
228 | 5.11M | template<typename T1, typename T2> constexpr T1 narrowing(T2 value) { return value; }Unexecuted instantiation: int o3tl::narrowing<int, unsigned long>(unsigned long) short o3tl::narrowing<short, int>(int) Line | Count | Source | 228 | 2.35k | template<typename T1, typename T2> constexpr T1 narrowing(T2 value) { return value; } |
Unexecuted instantiation: unsigned char o3tl::narrowing<unsigned char, int>(int) Unexecuted instantiation: unsigned char o3tl::narrowing<unsigned char, unsigned int>(unsigned int) Unexecuted instantiation: int o3tl::narrowing<int, float>(float) int o3tl::narrowing<int, long>(long) Line | Count | Source | 228 | 33.5k | template<typename T1, typename T2> constexpr T1 narrowing(T2 value) { return value; } |
unsigned short o3tl::narrowing<unsigned short, unsigned long>(unsigned long) Line | Count | Source | 228 | 137k | template<typename T1, typename T2> constexpr T1 narrowing(T2 value) { return value; } |
Unexecuted instantiation: int o3tl::narrowing<int, int>(int) unsigned short o3tl::narrowing<unsigned short, RES_POOL_COLLFMT_TYPE>(RES_POOL_COLLFMT_TYPE) Line | Count | Source | 228 | 185k | template<typename T1, typename T2> constexpr T1 narrowing(T2 value) { return value; } |
unsigned short o3tl::narrowing<unsigned short, int>(int) Line | Count | Source | 228 | 3.50M | template<typename T1, typename T2> constexpr T1 narrowing(T2 value) { return value; } |
unsigned short o3tl::narrowing<unsigned short, long>(long) Line | Count | Source | 228 | 958k | template<typename T1, typename T2> constexpr T1 narrowing(T2 value) { return value; } |
unsigned short o3tl::narrowing<unsigned short, unsigned char>(unsigned char) Line | Count | Source | 228 | 30.9k | template<typename T1, typename T2> constexpr T1 narrowing(T2 value) { return value; } |
unsigned short o3tl::narrowing<unsigned short, short>(short) Line | Count | Source | 228 | 113k | template<typename T1, typename T2> constexpr T1 narrowing(T2 value) { return value; } |
Unexecuted instantiation: unsigned short o3tl::narrowing<unsigned short, TOXSortType>(TOXSortType) unsigned short o3tl::narrowing<unsigned short, TypedWhichId<SwFormatEndAtTextEnd> >(TypedWhichId<SwFormatEndAtTextEnd>) Line | Count | Source | 228 | 96 | template<typename T1, typename T2> constexpr T1 narrowing(T2 value) { return value; } |
unsigned short o3tl::narrowing<unsigned short, TypedWhichId<SwFormatFootnoteAtTextEnd> >(TypedWhichId<SwFormatFootnoteAtTextEnd>) Line | Count | Source | 228 | 96 | template<typename T1, typename T2> constexpr T1 narrowing(T2 value) { return value; } |
unsigned short o3tl::narrowing<unsigned short, RES_POOL_CHRFMT_TYPE>(RES_POOL_CHRFMT_TYPE) Line | Count | Source | 228 | 20.2k | template<typename T1, typename T2> constexpr T1 narrowing(T2 value) { return value; } |
Unexecuted instantiation: short o3tl::narrowing<short, unsigned short>(unsigned short) unsigned short o3tl::narrowing<unsigned short, TypedWhichId<SvxFrameDirectionItem> >(TypedWhichId<SvxFrameDirectionItem>) Line | Count | Source | 228 | 30 | template<typename T1, typename T2> constexpr T1 narrowing(T2 value) { return value; } |
unsigned short o3tl::narrowing<unsigned short, unsigned int>(unsigned int) Line | Count | Source | 228 | 96.6k | template<typename T1, typename T2> constexpr T1 narrowing(T2 value) { return value; } |
Unexecuted instantiation: unsigned short o3tl::narrowing<unsigned short, SwCursorShell::CursorFlag>(SwCursorShell::CursorFlag) unsigned short o3tl::narrowing<unsigned short, RES_POOL_PAGEFMT_TYPE>(RES_POOL_PAGEFMT_TYPE) Line | Count | Source | 228 | 5.20k | template<typename T1, typename T2> constexpr T1 narrowing(T2 value) { return value; } |
unsigned short o3tl::narrowing<unsigned short, double>(double) Line | Count | Source | 228 | 11.7k | template<typename T1, typename T2> constexpr T1 narrowing(T2 value) { return value; } |
Unexecuted instantiation: unsigned short o3tl::narrowing<unsigned short, ToxAuthorityField>(ToxAuthorityField) unsigned short o3tl::narrowing<unsigned short, unsigned short>(unsigned short) Line | Count | Source | 228 | 11.8k | template<typename T1, typename T2> constexpr T1 narrowing(T2 value) { return value; } |
Unexecuted instantiation: unsigned short o3tl::narrowing<unsigned short, bool>(bool) Unexecuted instantiation: unsigned short o3tl::narrowing<unsigned short, SvxLinkInsertMode>(SvxLinkInsertMode) unsigned short o3tl::narrowing<unsigned short, TypedWhichId<SwFormatFrameSize> >(TypedWhichId<SwFormatFrameSize>) Line | Count | Source | 228 | 60 | template<typename T1, typename T2> constexpr T1 narrowing(T2 value) { return value; } |
unsigned short o3tl::narrowing<unsigned short, TypedWhichId<SvxLRSpaceItem> >(TypedWhichId<SvxLRSpaceItem>) Line | Count | Source | 228 | 20 | template<typename T1, typename T2> constexpr T1 narrowing(T2 value) { return value; } |
unsigned short o3tl::narrowing<unsigned short, TypedWhichId<SvxULSpaceItem> >(TypedWhichId<SvxULSpaceItem>) Line | Count | Source | 228 | 20 | template<typename T1, typename T2> constexpr T1 narrowing(T2 value) { return value; } |
unsigned short o3tl::narrowing<unsigned short, TypedWhichId<SwFormatPageDesc> >(TypedWhichId<SwFormatPageDesc>) Line | Count | Source | 228 | 10 | template<typename T1, typename T2> constexpr T1 narrowing(T2 value) { return value; } |
unsigned short o3tl::narrowing<unsigned short, TypedWhichId<SvxFormatBreakItem> >(TypedWhichId<SvxFormatBreakItem>) Line | Count | Source | 228 | 20 | template<typename T1, typename T2> constexpr T1 narrowing(T2 value) { return value; } |
unsigned short o3tl::narrowing<unsigned short, TypedWhichId<SwFormatHoriOrient> >(TypedWhichId<SwFormatHoriOrient>) Line | Count | Source | 228 | 10 | template<typename T1, typename T2> constexpr T1 narrowing(T2 value) { return value; } |
unsigned short o3tl::narrowing<unsigned short, TypedWhichId<SvxBrushItem> >(TypedWhichId<SvxBrushItem>) Line | Count | Source | 228 | 60 | template<typename T1, typename T2> constexpr T1 narrowing(T2 value) { return value; } |
unsigned short o3tl::narrowing<unsigned short, TypedWhichId<SvxShadowItem> >(TypedWhichId<SvxShadowItem>) Line | Count | Source | 228 | 10 | template<typename T1, typename T2> constexpr T1 narrowing(T2 value) { return value; } |
unsigned short o3tl::narrowing<unsigned short, TypedWhichId<SvxFormatKeepItem> >(TypedWhichId<SvxFormatKeepItem>) Line | Count | Source | 228 | 10 | template<typename T1, typename T2> constexpr T1 narrowing(T2 value) { return value; } |
unsigned short o3tl::narrowing<unsigned short, TypedWhichId<SwFormatLayoutSplit> >(TypedWhichId<SwFormatLayoutSplit>) Line | Count | Source | 228 | 10 | template<typename T1, typename T2> constexpr T1 narrowing(T2 value) { return value; } |
unsigned short o3tl::narrowing<unsigned short, TypedWhichId<SvXMLAttrContainerItem> >(TypedWhichId<SvXMLAttrContainerItem>) Line | Count | Source | 228 | 30 | template<typename T1, typename T2> constexpr T1 narrowing(T2 value) { return value; } |
unsigned short o3tl::narrowing<unsigned short, TypedWhichId<SfxBoolItem> >(TypedWhichId<SfxBoolItem>) Line | Count | Source | 228 | 10 | template<typename T1, typename T2> constexpr T1 narrowing(T2 value) { return value; } |
unsigned short o3tl::narrowing<unsigned short, TypedWhichId<SvxPrintItem> >(TypedWhichId<SvxPrintItem>) Line | Count | Source | 228 | 20 | template<typename T1, typename T2> constexpr T1 narrowing(T2 value) { return value; } |
unsigned short o3tl::narrowing<unsigned short, TypedWhichId<SwFormatRowSplit> >(TypedWhichId<SwFormatRowSplit>) Line | Count | Source | 228 | 20 | template<typename T1, typename T2> constexpr T1 narrowing(T2 value) { return value; } |
unsigned short o3tl::narrowing<unsigned short, TypedWhichId<SwFormatVertOrient> >(TypedWhichId<SwFormatVertOrient>) Line | Count | Source | 228 | 10 | template<typename T1, typename T2> constexpr T1 narrowing(T2 value) { return value; } |
unsigned short o3tl::narrowing<unsigned short, TypedWhichId<SvxBoxItem> >(TypedWhichId<SvxBoxItem>) Line | Count | Source | 228 | 150 | template<typename T1, typename T2> constexpr T1 narrowing(T2 value) { return value; } |
|
229 | | |
230 | | // A helper for taking care of signed/unsigned comparisons in constant bounds case |
231 | | // Should avoid Coverity warnings like "cid#1618764 Operands don't affect result" |
232 | | template <typename I, I Min = std::template numeric_limits<I>::min(), |
233 | | I Max = std::template numeric_limits<I>::max(), |
234 | | std::enable_if_t<std::is_integral_v<I> && (Min <= 0) && (Max > 0), int> = 0> |
235 | | struct ValidRange |
236 | | { |
237 | | using SI = std::make_signed_t<I>; |
238 | | using UI = std::make_unsigned_t<I>; |
239 | | |
240 | | template <typename I2, std::enable_if_t<std::is_integral_v<I2>, int> = 0> |
241 | | static constexpr bool isAbove(I2 n) |
242 | 57.8k | { |
243 | 57.8k | using UI2 = std::make_unsigned_t<I2>; |
244 | | if constexpr (static_cast<UI2>(std::numeric_limits<I2>::max()) <= static_cast<UI>(Max)) |
245 | 57.8k | return false; |
246 | | else if constexpr (std::is_signed_v<I> == std::is_signed_v<I2>) |
247 | 0 | return n > Max; |
248 | | else if constexpr (std::is_signed_v<I>) // I2 is unsigned |
249 | 0 | return n > static_cast<UI>(Max); |
250 | | else // I is unsigned, I2 is signed |
251 | 0 | return n > 0 && static_cast<UI2>(n) > Max; |
252 | 57.8k | } Unexecuted instantiation: _ZN4o3tl10ValidRangeIlLln922337203685477ELl922337203685477ELi0EE7isAboveIhTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIlLln922337203685477ELl922337203685477ELi0EE7isAboveIDsTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIlLln922337203685477ELl922337203685477ELi0EE7isAboveIsTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIlLln922337203685477ELl922337203685477ELi0EE7isAboveItTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIlLln922337203685477ELl922337203685477ELi0EE7isAboveIiTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIlLln922337203685477ELl922337203685477ELi0EE7isAboveIjTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIlLln922337203685477ELl922337203685477ELi0EE7isAboveIlTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIlLln922337203685477ELl922337203685477ELi0EE7isAboveImTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeImLm0ELm18446744073709551615ELi0EE7isAboveIlTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIDsLDs0ELDs65535ELi0EE7isAboveIlTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIhLh0ELh255ELi0EE7isAboveIlTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIsLsn32768ELs32767ELi0EE7isAboveIlTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeItLt0ELt65535ELi0EE7isAboveIlTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIiLin2147483648ELi2147483647ELi0EE7isAboveIlTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIjLj0ELj4294967295ELi0EE7isAboveIlTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIlLln9223372036854775808ELl9223372036854775807ELi0EE7isAboveIlTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIDsLDs0ELDs65535ELi0EE7isAboveIDsTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIDsLDs0ELDs65535ELi0EE7isAboveIhTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIDsLDs0ELDs65535ELi0EE7isAboveIsTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIDsLDs0ELDs65535ELi0EE7isAboveItTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIDsLDs0ELDs65535ELi0EE7isAboveIiTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIDsLDs0ELDs65535ELi0EE7isAboveIjTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIDsLDs0ELDs65535ELi0EE7isAboveImTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIhLh0ELh255ELi0EE7isAboveIDsTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIhLh0ELh255ELi0EE7isAboveIhTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIhLh0ELh255ELi0EE7isAboveIsTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIhLh0ELh255ELi0EE7isAboveItTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIhLh0ELh255ELi0EE7isAboveIiTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIhLh0ELh255ELi0EE7isAboveIjTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIhLh0ELh255ELi0EE7isAboveImTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIsLsn32768ELs32767ELi0EE7isAboveIDsTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIsLsn32768ELs32767ELi0EE7isAboveIhTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIsLsn32768ELs32767ELi0EE7isAboveIsTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIsLsn32768ELs32767ELi0EE7isAboveItTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIsLsn32768ELs32767ELi0EE7isAboveIiTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIsLsn32768ELs32767ELi0EE7isAboveIjTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIsLsn32768ELs32767ELi0EE7isAboveImTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeItLt0ELt65535ELi0EE7isAboveIDsTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeItLt0ELt65535ELi0EE7isAboveIhTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeItLt0ELt65535ELi0EE7isAboveIsTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeItLt0ELt65535ELi0EE7isAboveItTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeItLt0ELt65535ELi0EE7isAboveIiTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeItLt0ELt65535ELi0EE7isAboveIjTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeItLt0ELt65535ELi0EE7isAboveImTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIiLin2147483648ELi2147483647ELi0EE7isAboveIDsTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIiLin2147483648ELi2147483647ELi0EE7isAboveIhTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIiLin2147483648ELi2147483647ELi0EE7isAboveIsTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIiLin2147483648ELi2147483647ELi0EE7isAboveItTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ _ZN4o3tl10ValidRangeIiLin2147483648ELi2147483647ELi0EE7isAboveIiTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Line | Count | Source | 242 | 57.8k | { | 243 | 57.8k | using UI2 = std::make_unsigned_t<I2>; | 244 | | if constexpr (static_cast<UI2>(std::numeric_limits<I2>::max()) <= static_cast<UI>(Max)) | 245 | 57.8k | return false; | 246 | | else if constexpr (std::is_signed_v<I> == std::is_signed_v<I2>) | 247 | | return n > Max; | 248 | | else if constexpr (std::is_signed_v<I>) // I2 is unsigned | 249 | | return n > static_cast<UI>(Max); | 250 | | else // I is unsigned, I2 is signed | 251 | | return n > 0 && static_cast<UI2>(n) > Max; | 252 | 57.8k | } |
Unexecuted instantiation: _ZN4o3tl10ValidRangeIiLin2147483648ELi2147483647ELi0EE7isAboveIjTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIiLin2147483648ELi2147483647ELi0EE7isAboveImTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIjLj0ELj4294967295ELi0EE7isAboveIDsTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIjLj0ELj4294967295ELi0EE7isAboveIhTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIjLj0ELj4294967295ELi0EE7isAboveIsTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIjLj0ELj4294967295ELi0EE7isAboveItTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIjLj0ELj4294967295ELi0EE7isAboveIiTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIjLj0ELj4294967295ELi0EE7isAboveIjTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIjLj0ELj4294967295ELi0EE7isAboveImTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIlLln9223372036854775808ELl9223372036854775807ELi0EE7isAboveIDsTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIlLln9223372036854775808ELl9223372036854775807ELi0EE7isAboveIhTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIlLln9223372036854775808ELl9223372036854775807ELi0EE7isAboveIsTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIlLln9223372036854775808ELl9223372036854775807ELi0EE7isAboveItTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIlLln9223372036854775808ELl9223372036854775807ELi0EE7isAboveIiTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIlLln9223372036854775808ELl9223372036854775807ELi0EE7isAboveIjTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIlLln9223372036854775808ELl9223372036854775807ELi0EE7isAboveImTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeImLm0ELm18446744073709551615ELi0EE7isAboveIDsTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeImLm0ELm18446744073709551615ELi0EE7isAboveIhTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeImLm0ELm18446744073709551615ELi0EE7isAboveIsTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeImLm0ELm18446744073709551615ELi0EE7isAboveItTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeImLm0ELm18446744073709551615ELi0EE7isAboveIiTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeImLm0ELm18446744073709551615ELi0EE7isAboveIjTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeImLm0ELm18446744073709551615ELi0EE7isAboveImTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ |
253 | | |
254 | | template <typename I2, std::enable_if_t<std::is_integral_v<I2>, int> = 0> |
255 | | static constexpr bool isBelow(I2 n) |
256 | 57.8k | { |
257 | 57.8k | using SI2 = std::make_signed_t<I2>; |
258 | | if constexpr (static_cast<SI2>(std::numeric_limits<I2>::min()) >= static_cast<SI>(Min)) |
259 | 57.8k | return false; // Covers all I2 unsigned |
260 | | else if constexpr (std::is_signed_v<I> == std::is_signed_v<I2>) |
261 | 0 | return n < Min; |
262 | | else // I is unsigned, I2 is signed |
263 | 0 | return n < 0; |
264 | 57.8k | } Unexecuted instantiation: _ZN4o3tl10ValidRangeIlLln922337203685477ELl922337203685477ELi0EE7isBelowIhTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIlLln922337203685477ELl922337203685477ELi0EE7isBelowIDsTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIlLln922337203685477ELl922337203685477ELi0EE7isBelowIsTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIlLln922337203685477ELl922337203685477ELi0EE7isBelowItTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIlLln922337203685477ELl922337203685477ELi0EE7isBelowIiTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIlLln922337203685477ELl922337203685477ELi0EE7isBelowIjTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIlLln922337203685477ELl922337203685477ELi0EE7isBelowIlTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIlLln922337203685477ELl922337203685477ELi0EE7isBelowImTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeImLm0ELm18446744073709551615ELi0EE7isBelowIlTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIDsLDs0ELDs65535ELi0EE7isBelowIlTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIhLh0ELh255ELi0EE7isBelowIlTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIsLsn32768ELs32767ELi0EE7isBelowIlTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeItLt0ELt65535ELi0EE7isBelowIlTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIiLin2147483648ELi2147483647ELi0EE7isBelowIlTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIjLj0ELj4294967295ELi0EE7isBelowIlTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIlLln9223372036854775808ELl9223372036854775807ELi0EE7isBelowIlTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIDsLDs0ELDs65535ELi0EE7isBelowIDsTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIDsLDs0ELDs65535ELi0EE7isBelowIhTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIDsLDs0ELDs65535ELi0EE7isBelowIsTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIDsLDs0ELDs65535ELi0EE7isBelowItTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIDsLDs0ELDs65535ELi0EE7isBelowIiTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIDsLDs0ELDs65535ELi0EE7isBelowIjTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIDsLDs0ELDs65535ELi0EE7isBelowImTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIhLh0ELh255ELi0EE7isBelowIDsTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIhLh0ELh255ELi0EE7isBelowIhTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIhLh0ELh255ELi0EE7isBelowIsTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIhLh0ELh255ELi0EE7isBelowItTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIhLh0ELh255ELi0EE7isBelowIiTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIhLh0ELh255ELi0EE7isBelowIjTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIhLh0ELh255ELi0EE7isBelowImTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIsLsn32768ELs32767ELi0EE7isBelowIDsTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIsLsn32768ELs32767ELi0EE7isBelowIhTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIsLsn32768ELs32767ELi0EE7isBelowIsTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIsLsn32768ELs32767ELi0EE7isBelowItTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIsLsn32768ELs32767ELi0EE7isBelowIiTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIsLsn32768ELs32767ELi0EE7isBelowIjTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIsLsn32768ELs32767ELi0EE7isBelowImTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeItLt0ELt65535ELi0EE7isBelowIDsTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeItLt0ELt65535ELi0EE7isBelowIhTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeItLt0ELt65535ELi0EE7isBelowIsTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeItLt0ELt65535ELi0EE7isBelowItTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeItLt0ELt65535ELi0EE7isBelowIiTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeItLt0ELt65535ELi0EE7isBelowIjTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeItLt0ELt65535ELi0EE7isBelowImTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIiLin2147483648ELi2147483647ELi0EE7isBelowIDsTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIiLin2147483648ELi2147483647ELi0EE7isBelowIhTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIiLin2147483648ELi2147483647ELi0EE7isBelowIsTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIiLin2147483648ELi2147483647ELi0EE7isBelowItTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ _ZN4o3tl10ValidRangeIiLin2147483648ELi2147483647ELi0EE7isBelowIiTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Line | Count | Source | 256 | 57.8k | { | 257 | 57.8k | using SI2 = std::make_signed_t<I2>; | 258 | | if constexpr (static_cast<SI2>(std::numeric_limits<I2>::min()) >= static_cast<SI>(Min)) | 259 | 57.8k | return false; // Covers all I2 unsigned | 260 | | else if constexpr (std::is_signed_v<I> == std::is_signed_v<I2>) | 261 | | return n < Min; | 262 | | else // I is unsigned, I2 is signed | 263 | | return n < 0; | 264 | 57.8k | } |
Unexecuted instantiation: _ZN4o3tl10ValidRangeIiLin2147483648ELi2147483647ELi0EE7isBelowIjTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIiLin2147483648ELi2147483647ELi0EE7isBelowImTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIjLj0ELj4294967295ELi0EE7isBelowIDsTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIjLj0ELj4294967295ELi0EE7isBelowIhTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIjLj0ELj4294967295ELi0EE7isBelowIsTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIjLj0ELj4294967295ELi0EE7isBelowItTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIjLj0ELj4294967295ELi0EE7isBelowIiTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIjLj0ELj4294967295ELi0EE7isBelowIjTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIjLj0ELj4294967295ELi0EE7isBelowImTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIlLln9223372036854775808ELl9223372036854775807ELi0EE7isBelowIDsTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIlLln9223372036854775808ELl9223372036854775807ELi0EE7isBelowIhTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIlLln9223372036854775808ELl9223372036854775807ELi0EE7isBelowIsTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIlLln9223372036854775808ELl9223372036854775807ELi0EE7isBelowItTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIlLln9223372036854775808ELl9223372036854775807ELi0EE7isBelowIiTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIlLln9223372036854775808ELl9223372036854775807ELi0EE7isBelowIjTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeIlLln9223372036854775808ELl9223372036854775807ELi0EE7isBelowImTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeImLm0ELm18446744073709551615ELi0EE7isBelowIDsTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeImLm0ELm18446744073709551615ELi0EE7isBelowIhTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeImLm0ELm18446744073709551615ELi0EE7isBelowIsTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeImLm0ELm18446744073709551615ELi0EE7isBelowItTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeImLm0ELm18446744073709551615ELi0EE7isBelowIiTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeImLm0ELm18446744073709551615ELi0EE7isBelowIjTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ Unexecuted instantiation: _ZN4o3tl10ValidRangeImLm0ELm18446744073709551615ELi0EE7isBelowImTnNSt3__19enable_ifIXsr3stdE13is_integral_vIT_EEiE4typeELi0EEEbS5_ |
265 | | |
266 | | template <typename I2, std::enable_if_t<std::is_integral_v<I2>, int> = 0> |
267 | | static constexpr bool isOutside(I2 n) |
268 | | { |
269 | | return isAbove(n) || isBelow(n); |
270 | | } |
271 | | |
272 | | template <typename I2, std::enable_if_t<std::is_integral_v<I2>, int> = 0> |
273 | | static constexpr bool isInside(I2 n) |
274 | | { |
275 | | return !isOutside(n); |
276 | | } |
277 | | }; |
278 | | |
279 | | } |
280 | | |
281 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |