mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-20 23:29:12 +01:00
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>
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user