@@ -965,7 +965,7 @@ template<extracted_entities Entities, auto Ext, TypeList NumFrom, TypeList DenFr
965
965
}();
966
966
967
967
if constexpr (Entities == extracted_entities::numerators || Entities == extracted_entities::denominators)
968
- return min (res, convertible_impl (Ext.from , Ext.to ));
968
+ return min (res, convertible (Ext.from , Ext.to ));
969
969
else
970
970
return res;
971
971
}
@@ -998,26 +998,26 @@ template<typename NumFrom, typename... NumsFrom, typename DenFrom, typename... D
998
998
if constexpr (max_compl > 0 ) {
999
999
if constexpr (num_from_compl == max_compl) {
1000
1000
constexpr auto res = explode_to_equation (NumFrom{});
1001
- return convertible_impl (
1001
+ return convertible (
1002
1002
(res.equation * ... * map_power (NumsFrom{})) / (map_power (DenFrom{}) * ... * map_power (DensFrom{})),
1003
1003
(map_power (NumTo{}) * ... * map_power (NumsTo{})) / (map_power (DenTo{}) * ... * map_power (DensTo{})));
1004
1004
} else if constexpr (den_from_compl == max_compl) {
1005
1005
constexpr auto res = explode_to_equation (DenFrom{});
1006
- return convertible_impl (
1006
+ return convertible (
1007
1007
(map_power (NumFrom{}) * ... * map_power (NumsFrom{})) / (res.equation * ... * map_power (DensFrom{})),
1008
1008
(map_power (NumTo{}) * ... * map_power (NumsTo{})) / (map_power (DenTo{}) * ... * map_power (DensTo{})));
1009
1009
} else if constexpr (num_to_compl == max_compl) {
1010
1010
constexpr auto res = explode_to_equation (NumTo{});
1011
- return min (res.result , convertible_impl ((map_power (NumFrom{}) * ... * map_power (NumsFrom{})) /
1012
- (map_power (DenFrom{}) * ... * map_power (DensFrom{})),
1013
- (res.equation * ... * map_power (NumsTo{})) /
1014
- (map_power (DenTo{}) * ... * map_power (DensTo{}))));
1011
+ return min (res.result , convertible ((map_power (NumFrom{}) * ... * map_power (NumsFrom{})) /
1012
+ (map_power (DenFrom{}) * ... * map_power (DensFrom{})),
1013
+ (res.equation * ... * map_power (NumsTo{})) /
1014
+ (map_power (DenTo{}) * ... * map_power (DensTo{}))));
1015
1015
} else {
1016
1016
constexpr auto res = explode_to_equation (DenTo{});
1017
- return min (res.result , convertible_impl ((map_power (NumFrom{}) * ... * map_power (NumsFrom{})) /
1018
- (map_power (DenFrom{}) * ... * map_power (DensFrom{})),
1019
- (map_power (NumTo{}) * ... * map_power (NumsTo{})) /
1020
- (res.equation * ... * map_power (DensTo{}))));
1017
+ return min (res.result , convertible ((map_power (NumFrom{}) * ... * map_power (NumsFrom{})) /
1018
+ (map_power (DenFrom{}) * ... * map_power (DensFrom{})),
1019
+ (map_power (NumTo{}) * ... * map_power (NumsTo{})) /
1020
+ (res.equation * ... * map_power (DensTo{}))));
1021
1021
}
1022
1022
}
1023
1023
}
@@ -1043,19 +1043,19 @@ template<typename DenFrom, typename... DensFrom, typename NumTo, typename... Num
1043
1043
if constexpr (max_compl > 0 ) {
1044
1044
if constexpr (den_from_compl == max_compl) {
1045
1045
constexpr auto res = explode_to_equation (DenFrom{});
1046
- return convertible_impl (
1046
+ return convertible (
1047
1047
dimensionless / (res.equation * ... * map_power (DensFrom{})),
1048
1048
(map_power (NumTo{}) * ... * map_power (NumsTo{})) / (map_power (DenTo{}) * ... * map_power (DensTo{})));
1049
1049
} else if constexpr (num_to_compl == max_compl) {
1050
1050
constexpr auto res = explode_to_equation (NumTo{});
1051
- return min (res.result , convertible_impl (dimensionless / (map_power (DenFrom{}) * ... * map_power (DensFrom{})),
1052
- (res.equation * ... * map_power (NumsTo{})) /
1053
- (map_power (DenTo{}) * ... * map_power (DensTo{}))));
1051
+ return min (res.result , convertible (dimensionless / (map_power (DenFrom{}) * ... * map_power (DensFrom{})),
1052
+ (res.equation * ... * map_power (NumsTo{})) /
1053
+ (map_power (DenTo{}) * ... * map_power (DensTo{}))));
1054
1054
} else {
1055
1055
constexpr auto res = explode_to_equation (DenTo{});
1056
- return min (res.result , convertible_impl (dimensionless / (map_power (DenFrom{}) * ... * map_power (DensFrom{})),
1057
- (map_power (NumTo{}) * ... * map_power (NumsTo{})) /
1058
- (res.equation * ... * map_power (DensTo{}))));
1056
+ return min (res.result , convertible (dimensionless / (map_power (DenFrom{}) * ... * map_power (DensFrom{})),
1057
+ (map_power (NumTo{}) * ... * map_power (NumsTo{})) /
1058
+ (res.equation * ... * map_power (DensTo{}))));
1059
1059
}
1060
1060
}
1061
1061
}
@@ -1081,19 +1081,19 @@ template<typename NumFrom, typename... NumsFrom, typename NumTo, typename... Num
1081
1081
if constexpr (max_compl > 0 ) {
1082
1082
if constexpr (num_from_compl == max_compl) {
1083
1083
constexpr auto res = explode_to_equation (NumFrom{});
1084
- return convertible_impl (
1084
+ return convertible (
1085
1085
(res.equation * ... * map_power (NumsFrom{})),
1086
1086
(map_power (NumTo{}) * ... * map_power (NumsTo{})) / (map_power (DenTo{}) * ... * map_power (DensTo{})));
1087
1087
} else if constexpr (num_to_compl == max_compl) {
1088
1088
constexpr auto res = explode_to_equation (NumTo{});
1089
- return min (res.result , convertible_impl ((map_power (NumFrom{}) * ... * map_power (NumsFrom{})),
1090
- (res.equation * ... * map_power (NumsTo{})) /
1091
- (map_power (DenTo{}) * ... * map_power (DensTo{}))));
1089
+ return min (res.result , convertible ((map_power (NumFrom{}) * ... * map_power (NumsFrom{})),
1090
+ (res.equation * ... * map_power (NumsTo{})) /
1091
+ (map_power (DenTo{}) * ... * map_power (DensTo{}))));
1092
1092
} else {
1093
1093
constexpr auto res = explode_to_equation (DenTo{});
1094
- return min (res.result , convertible_impl ((map_power (NumFrom{}) * ... * map_power (NumsFrom{})),
1095
- (map_power (NumTo{}) * ... * map_power (NumsTo{})) /
1096
- (res.equation * ... * map_power (DensTo{}))));
1094
+ return min (res.result , convertible ((map_power (NumFrom{}) * ... * map_power (NumsFrom{})),
1095
+ (map_power (NumTo{}) * ... * map_power (NumsTo{})) /
1096
+ (res.equation * ... * map_power (DensTo{}))));
1097
1097
}
1098
1098
}
1099
1099
}
@@ -1120,19 +1120,19 @@ template<typename NumFrom, typename... NumsFrom, typename DenFrom, typename... D
1120
1120
if constexpr (max_compl > 0 ) {
1121
1121
if constexpr (num_from_compl == max_compl) {
1122
1122
constexpr auto res = explode_to_equation (NumFrom{});
1123
- return convertible_impl (
1123
+ return convertible (
1124
1124
(res.equation * ... * map_power (NumsFrom{})) / (map_power (DenFrom{}) * ... * map_power (DensFrom{})),
1125
1125
dimensionless / (map_power (DenTo{}) * ... * map_power (DensTo{})));
1126
1126
} else if constexpr (den_from_compl == max_compl) {
1127
1127
constexpr auto res = explode_to_equation (DenFrom{});
1128
- return convertible_impl (
1128
+ return convertible (
1129
1129
(map_power (NumFrom{}) * ... * map_power (NumsFrom{})) / (res.equation * ... * map_power (DensFrom{})),
1130
1130
dimensionless / (map_power (DenTo{}) * ... * map_power (DensTo{})));
1131
1131
} else {
1132
1132
constexpr auto res = explode_to_equation (DenTo{});
1133
- return min (res.result , convertible_impl ((map_power (NumFrom{}) * ... * map_power (NumsFrom{})) /
1134
- (map_power (DenFrom{}) * ... * map_power (DensFrom{})),
1135
- dimensionless / (res.equation * ... * map_power (DensTo{}))));
1133
+ return min (res.result , convertible ((map_power (NumFrom{}) * ... * map_power (NumsFrom{})) /
1134
+ (map_power (DenFrom{}) * ... * map_power (DensFrom{})),
1135
+ dimensionless / (res.equation * ... * map_power (DensTo{}))));
1136
1136
}
1137
1137
}
1138
1138
}
@@ -1159,19 +1159,19 @@ template<typename NumFrom, typename... NumsFrom, typename DenFrom, typename... D
1159
1159
if constexpr (max_compl > 0 ) {
1160
1160
if constexpr (num_from_compl == max_compl) {
1161
1161
constexpr auto res = explode_to_equation (NumFrom{});
1162
- return convertible_impl (
1162
+ return convertible (
1163
1163
(res.equation * ... * map_power (NumsFrom{})) / (map_power (DenFrom{}) * ... * map_power (DensFrom{})),
1164
1164
(map_power (NumTo{}) * ... * map_power (NumsTo{})));
1165
1165
} else if constexpr (den_from_compl == max_compl) {
1166
1166
constexpr auto res = explode_to_equation (DenFrom{});
1167
- return convertible_impl (
1167
+ return convertible (
1168
1168
(map_power (NumFrom{}) * ... * map_power (NumsFrom{})) / (res.equation * ... * map_power (DensFrom{})),
1169
1169
(map_power (NumTo{}) * ... * map_power (NumsTo{})));
1170
1170
} else {
1171
1171
constexpr auto res = explode_to_equation (NumTo{});
1172
- return min (res.result , convertible_impl ((map_power (NumFrom{}) * ... * map_power (NumsFrom{})) /
1173
- (map_power (DenFrom{}) * ... * map_power (DensFrom{})),
1174
- (res.equation * ... * map_power (NumsTo{}))));
1172
+ return min (res.result , convertible ((map_power (NumFrom{}) * ... * map_power (NumsFrom{})) /
1173
+ (map_power (DenFrom{}) * ... * map_power (DensFrom{})),
1174
+ (res.equation * ... * map_power (NumsTo{}))));
1175
1175
}
1176
1176
}
1177
1177
}
@@ -1193,12 +1193,12 @@ template<typename NumFrom, typename... NumsFrom, typename NumTo, typename... Num
1193
1193
if constexpr (max_compl > 0 ) {
1194
1194
if constexpr (num_from_compl == max_compl) {
1195
1195
constexpr auto res = explode_to_equation (NumFrom{});
1196
- return convertible_impl ((res.equation * ... * map_power (NumsFrom{})),
1197
- (map_power (NumTo{}) * ... * map_power (NumsTo{})));
1196
+ return convertible ((res.equation * ... * map_power (NumsFrom{})),
1197
+ (map_power (NumTo{}) * ... * map_power (NumsTo{})));
1198
1198
} else {
1199
1199
constexpr auto res = explode_to_equation (NumTo{});
1200
- return min (res.result , convertible_impl ((map_power (NumFrom{}) * ... * map_power (NumsFrom{})),
1201
- (res.equation * ... * map_power (NumsTo{}))));
1200
+ return min (res.result , convertible ((map_power (NumFrom{}) * ... * map_power (NumsFrom{})),
1201
+ (res.equation * ... * map_power (NumsTo{}))));
1202
1202
}
1203
1203
}
1204
1204
}
@@ -1220,12 +1220,12 @@ template<typename DenFrom, typename... DensFrom, typename DenTo, typename... Den
1220
1220
if constexpr (max_compl > 0 ) {
1221
1221
if constexpr (den_from_compl == max_compl) {
1222
1222
constexpr auto res = explode_to_equation (DenFrom{});
1223
- return convertible_impl (dimensionless / (res.equation * ... * map_power (DensFrom{})),
1224
- dimensionless / (map_power (DenTo{}) * ... * map_power (DensTo{})));
1223
+ return convertible (dimensionless / (res.equation * ... * map_power (DensFrom{})),
1224
+ dimensionless / (map_power (DenTo{}) * ... * map_power (DensTo{})));
1225
1225
} else {
1226
1226
constexpr auto res = explode_to_equation (DenTo{});
1227
- return min (res.result , convertible_impl (dimensionless / (map_power (DenFrom{}) * ... * map_power (DensFrom{})),
1228
- dimensionless / (res.equation * ... * map_power (DensTo{}))));
1227
+ return min (res.result , convertible (dimensionless / (map_power (DenFrom{}) * ... * map_power (DensFrom{})),
1228
+ dimensionless / (res.equation * ... * map_power (DensTo{}))));
1229
1229
}
1230
1230
}
1231
1231
}
@@ -1242,12 +1242,12 @@ template<typename NumFrom, typename... NumsFrom, typename DenTo, typename... Den
1242
1242
if constexpr (max_compl > 0 ) {
1243
1243
if constexpr (num_from_compl == max_compl) {
1244
1244
constexpr auto res = explode_to_equation (NumFrom{});
1245
- return convertible_impl ((res.equation * ... * map_power (NumsFrom{})),
1246
- dimensionless / (map_power (DenTo{}) * ... * map_power (DensTo{})));
1245
+ return convertible ((res.equation * ... * map_power (NumsFrom{})),
1246
+ dimensionless / (map_power (DenTo{}) * ... * map_power (DensTo{})));
1247
1247
} else {
1248
1248
constexpr auto res = explode_to_equation (DenTo{});
1249
- return min (res.result , convertible_impl ((map_power (NumFrom{}) * ... * map_power (NumsFrom{})),
1250
- dimensionless / (res.equation * ... * map_power (DensTo{}))));
1249
+ return min (res.result , convertible ((map_power (NumFrom{}) * ... * map_power (NumsFrom{})),
1250
+ dimensionless / (res.equation * ... * map_power (DensTo{}))));
1251
1251
}
1252
1252
}
1253
1253
}
@@ -1263,12 +1263,12 @@ template<typename DenFrom, typename... DensFrom, typename NumTo, typename... Num
1263
1263
if constexpr (max_compl > 0 ) {
1264
1264
if constexpr (den_from_compl == max_compl) {
1265
1265
constexpr auto res = explode_to_equation (DenFrom{});
1266
- return convertible_impl (dimensionless / (res.equation * ... * map_power (DensFrom{})),
1267
- (map_power (NumTo{}) * ... * map_power (NumsTo{})));
1266
+ return convertible (dimensionless / (res.equation * ... * map_power (DensFrom{})),
1267
+ (map_power (NumTo{}) * ... * map_power (NumsTo{})));
1268
1268
} else {
1269
1269
constexpr auto res = explode_to_equation (NumTo{});
1270
- return min (res.result , convertible_impl (dimensionless / (map_power (DenFrom{}) * ... * map_power (DensFrom{})),
1271
- (res.equation * ... * map_power (NumsTo{}))));
1270
+ return min (res.result , convertible (dimensionless / (map_power (DenFrom{}) * ... * map_power (DensFrom{})),
1271
+ (res.equation * ... * map_power (NumsTo{}))));
1272
1272
}
1273
1273
}
1274
1274
}
@@ -1356,11 +1356,11 @@ template<QuantitySpec From, QuantitySpec To>
1356
1356
};
1357
1357
if constexpr ((NamedQuantitySpec<decltype (From{})> && NamedQuantitySpec<decltype (To{})>) ||
1358
1358
get_complexity (From{}) == get_complexity (To{}))
1359
- return exploded_kind_result (convertible_impl (from_kind, to_kind));
1359
+ return exploded_kind_result (convertible (from_kind, to_kind));
1360
1360
else if constexpr (get_complexity (From{}) > get_complexity (To{}))
1361
- return exploded_kind_result (convertible_impl (explode<get_complexity (To{})>(from_kind).quantity , to_kind));
1361
+ return exploded_kind_result (convertible (explode<get_complexity (To{})>(from_kind).quantity , to_kind));
1362
1362
else
1363
- return exploded_kind_result (convertible_impl (from_kind, explode<get_complexity (From{})>(to_kind).quantity ));
1363
+ return exploded_kind_result (convertible (from_kind, explode<get_complexity (From{})>(to_kind).quantity ));
1364
1364
}
1365
1365
1366
1366
template <NamedQuantitySpec From, NamedQuantitySpec To>
@@ -1377,14 +1377,15 @@ template<NamedQuantitySpec From, NamedQuantitySpec To>
1377
1377
return no;
1378
1378
else if constexpr (get_complexity (From{}) != get_complexity (To{})) {
1379
1379
if constexpr (get_complexity (From{}) > get_complexity (To{}))
1380
- return convertible_impl (explode<get_complexity (To{})>(from).quantity , to);
1380
+ return convertible (explode<get_complexity (To{})>(from).quantity , to);
1381
1381
else {
1382
1382
auto res = explode<get_complexity (From{})>(to);
1383
- return min (res.result , convertible_impl (from, res.quantity ));
1383
+ return min (res.result , convertible (from, res.quantity ));
1384
1384
}
1385
1385
}
1386
1386
}
1387
1387
1388
+
1388
1389
template <QuantitySpec From, QuantitySpec To>
1389
1390
[[nodiscard]] consteval specs_convertible_result convertible_impl (From from, To to)
1390
1391
{
@@ -1406,45 +1407,54 @@ template<QuantitySpec From, QuantitySpec To>
1406
1407
else if constexpr (DerivedQuantitySpec<From>) {
1407
1408
auto res = explode<get_complexity (To{})>(from);
1408
1409
if constexpr (NamedQuantitySpec<decltype (res.quantity )>)
1409
- return convertible_impl (res.quantity , to);
1410
+ return convertible (res.quantity , to);
1410
1411
else if constexpr (requires { to._equation_ ; }) {
1411
1412
auto eq = explode_to_equation (to);
1412
- return min (eq.result , convertible_impl (res.quantity , eq.equation ));
1413
+ return min (eq.result , convertible (res.quantity , eq.equation ));
1413
1414
} else
1414
1415
return are_ingredients_convertible (from, to);
1415
1416
} else if constexpr (DerivedQuantitySpec<To>) {
1416
1417
auto res = explode<get_complexity (From{})>(to);
1417
1418
if constexpr (NamedQuantitySpec<decltype (res.quantity )>)
1418
- return min (res.result , convertible_impl (from, res.quantity ));
1419
+ return min (res.result , convertible (from, res.quantity ));
1419
1420
else if constexpr (requires { from._equation_ ; })
1420
- return min (res.result , convertible_impl (from._equation_ , res.quantity ));
1421
+ return min (res.result , convertible (from._equation_ , res.quantity ));
1421
1422
else
1422
1423
return min (res.result , are_ingredients_convertible (from, to));
1423
1424
}
1424
1425
// NOLINTEND(bugprone-branch-clone)
1425
1426
return no;
1426
1427
}
1427
1428
1429
+ template <QuantitySpec From, QuantitySpec To>
1430
+ constexpr specs_convertible_result convertible_result = convertible_impl(From{}, To{});
1431
+
1432
+ template <QuantitySpec From, QuantitySpec To>
1433
+ [[nodiscard]] consteval specs_convertible_result convertible (From, To)
1434
+ {
1435
+ return convertible_result<From, To>;
1436
+ }
1437
+
1428
1438
} // namespace detail
1429
1439
1430
1440
MP_UNITS_EXPORT_BEGIN
1431
1441
1432
1442
template <QuantitySpec From, QuantitySpec To>
1433
1443
[[nodiscard]] consteval bool implicitly_convertible (From from, To to)
1434
1444
{
1435
- return detail::convertible_impl (from, to) == detail::specs_convertible_result::yes;
1445
+ return detail::convertible (from, to) == detail::specs_convertible_result::yes;
1436
1446
}
1437
1447
1438
1448
template <QuantitySpec From, QuantitySpec To>
1439
1449
[[nodiscard]] consteval bool explicitly_convertible (From from, To to)
1440
1450
{
1441
- return detail::convertible_impl (from, to) >= detail::specs_convertible_result::explicit_conversion;
1451
+ return detail::convertible (from, to) >= detail::specs_convertible_result::explicit_conversion;
1442
1452
}
1443
1453
1444
1454
template <QuantitySpec From, QuantitySpec To>
1445
1455
[[nodiscard]] consteval bool castable (From from, To to)
1446
1456
{
1447
- return detail::convertible_impl (from, to) >= detail::specs_convertible_result::cast;
1457
+ return detail::convertible (from, to) >= detail::specs_convertible_result::cast;
1448
1458
}
1449
1459
1450
1460
template <QuantitySpec QS1, QuantitySpec QS2>
0 commit comments