refactor: some TODO comment addressed or removed

This commit is contained in:
Mateusz Pusz
2024-06-01 13:36:22 +02:00
parent 3c8a0212f0
commit 2adc9344ea
5 changed files with 7 additions and 20 deletions

View File

@@ -20,8 +20,9 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
// Copy-pasted C++ standard libraries to be replaced with `import std;` when available
// `#include <algorithm.h>` is too heavy to do in every translation unit
// Copy-pasted C++ standard libraries
// TODO To be replaced with `import std;` when available
// `#include <algorithm.h>` is too heavy to do in every translation unit
#pragma once

View File

@@ -295,17 +295,8 @@ template<typename T>
constexpr auto checked_square = [checked_multiply](auto a) { return checked_multiply(a, a); };
// TODO(chogg): Unify this implementation with the one in pow.h. That one takes its exponent as a
// template parameter, rather than a function parameter.
if (exp == 0) {
return T{1};
}
if (exp % 2 == 1) {
return checked_multiply(base, int_power(base, exp - 1));
}
if (exp == 0) return T{1};
if (exp % 2 == 1) return checked_multiply(base, int_power(base, exp - 1));
return checked_square(int_power(base, exp / 2));
}
@@ -340,7 +331,6 @@ template<typename T>
// The input is the desired result, but in a (wider) intermediate type. The point of this function
// is to cast to the desired type, but avoid overflow in doing so.
template<typename To, typename From>
// TODO(chogg): Migrate this to use `treat_as_floating_point`.
requires(!std::is_integral_v<To> || std::is_integral_v<From>)
[[nodiscard]] consteval To checked_static_cast(From x)
{

View File

@@ -552,11 +552,6 @@ template<std::intmax_t Num, std::intmax_t Den = 1, QuantitySpec Q>
requires detail::non_zero<Den>
[[nodiscard]] consteval QuantitySpec auto pow(Q q)
{
// TODO Does the below make sense?
// `2 * 2` should compare to `4`
// `2 * one * (2 * one)` should compare to `4 * one`
// `2 * rad * (2 * rad)` should compare to `4 * rad^2`
// all are dimensionless quantities :-(
if constexpr (Num == 0 || Q{} == dimensionless)
return dimensionless;
else if constexpr (detail::ratio{Num, Den} == 1)

View File

@@ -24,7 +24,6 @@
#pragma once
// IWYU pragma: private, include <mp-units/framework.h>
// TODO use <algorithm> when moved to C++20 modules (parsing takes too long for each translation unit)
#include <mp-units/bits/hacks.h>
#include <mp-units/bits/module_macros.h>
#include <mp-units/compat_macros.h>

View File

@@ -744,6 +744,8 @@ static_assert(4 / (2 * one) == 2 * one);
static_assert(4 * one / 2 == 2 * one);
static_assert(4 * one % (2 * one) == 0 * one);
static_assert(2 * rad * (2 * rad) == 4 * pow<2>(rad));
// modulo arithmetics
static_assert(5 * h % (120 * min) == 60 * min);
static_assert(300 * min % (2 * h) == 60 * min);