aboutsummaryrefslogtreecommitdiff
path: root/src/script/miniscript.cpp
diff options
context:
space:
mode:
authorPieter Wuille <pieter@wuille.net>2023-10-16 10:17:12 -0400
committerPieter Wuille <pieter@wuille.net>2024-05-03 11:38:14 -0400
commit63317103c9f2b0635558da814567bb79c17ae851 (patch)
treec65452686f05dc98f89a3ee405f4016d6d6d2dc9 /src/script/miniscript.cpp
parent70e4d6ff1d269abbda9dafae659e3da3ea17867a (diff)
miniscript: make operator_mst consteval
It seems modern compilers don't realize that all invocations of operator""_mst can be evaluated at compile time, despite the constexpr keyword. Since C++20, we can force them to evaluate at compile time, turning all the miniscript type constants into actual compile-time constants. It appears that MSVC does not support consteval operator"" when used inside certain expressions. For the few places where this happens, define a constant outside the operator call. Co-Authored-By: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com>
Diffstat (limited to 'src/script/miniscript.cpp')
-rw-r--r--src/script/miniscript.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/script/miniscript.cpp b/src/script/miniscript.cpp
index 344a81bdf0..455bd56283 100644
--- a/src/script/miniscript.cpp
+++ b/src/script/miniscript.cpp
@@ -231,7 +231,8 @@ Type ComputeType(Fragment fragment, Type x, Type y, Type z, const std::vector<Ty
Type acc_tl = "k"_mst;
for (size_t i = 0; i < sub_types.size(); ++i) {
Type t = sub_types[i];
- if (!(t << (i ? "Wdu"_mst : "Bdu"_mst))) return ""_mst; // Require Bdu, Wdu, Wdu, ...
+ static constexpr auto WDU{"Wdu"_mst}, BDU{"Bdu"_mst};
+ if (!(t << (i ? WDU : BDU))) return ""_mst; // Require Bdu, Wdu, Wdu, ...
if (!(t << "e"_mst)) all_e = false;
if (!(t << "m"_mst)) all_m = false;
if (t << "s"_mst) num_s += 1;