Skip to content

Commit

Permalink
Merge branch 'master' of github.com:mpusz/mp-units
Browse files Browse the repository at this point in the history
  • Loading branch information
mpusz committed Sep 26, 2023
2 parents bfbc178 + b5f966e commit eaf51c4
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/core/include/mp-units/bits/expression_template.h
Original file line number Diff line number Diff line change
Expand Up @@ -348,18 +348,16 @@ template<typename NumList, typename DenList, typename OneType, template<typename
/**
* @brief Creates an expression template spec based on provided numerator and denominator parts
*/
template<typename NumList, typename DenList, typename OneType, template<typename...> typename To>
using expr_make_spec = decltype(expr_make_spec_impl<NumList, DenList, OneType, To>());

template<typename NumList, typename DenList, typename OneType, template<typename, typename> typename Pred,
template<typename...> typename To>
[[nodiscard]] consteval auto get_optimized_expression()
{
using num_list = expr_consolidate<NumList>;
using den_list = expr_consolidate<DenList>;
using simple = expr_simplify<num_list, den_list, Pred>;
using expr = expr_make_spec<typename simple::num, typename simple::den, OneType, To>;
return expr{};
// the usage of `std::identity` below helps to resolve an using alias identifier to the actual
// type identifier in the clang compile-time errors
return std::identity{}(expr_make_spec_impl<typename simple::num, typename simple::den, OneType, To>());
}

/**
Expand Down Expand Up @@ -444,7 +442,9 @@ template<template<typename...> typename To, typename OneType, typename T>
[[nodiscard]] consteval auto expr_invert(T)
{
if constexpr (is_specialization_of<T, To>)
return expr_make_spec<typename T::_den_, typename T::_num_, OneType, To>{};
// the usage of `std::identity` below helps to resolve an using alias identifier to the actual
// type identifier in the clang compile-time errors
return std::identity{}(expr_make_spec_impl<typename T::_den_, typename T::_num_, OneType, To>());
else
return To<OneType, per<T>>{};
}
Expand Down

0 comments on commit eaf51c4

Please sign in to comment.