| 609 | /** Build a script by concatenating other scripts, or any argument accepted by CScript::operator<<. */ |
| 610 | template<typename... Ts> |
| 611 | CScript BuildScript(Ts&&... inputs) |
| 612 | { |
| 613 | CScript ret; |
| 614 | int cnt{0}; |
| 615 | |
| 616 | ([&ret, &cnt] (Ts&& input) { |
| 617 | if constexpr (std::is_same_v<std::remove_cv_t<std::remove_reference_t<Ts>>, CScript>) { |
| 618 | // If it is a CScript, extend ret with it. Move or copy the first element instead. |
| 619 | if (cnt == 0) { |
| 620 | ret = std::forward<Ts>(input); |
| 621 | } else { |
| 622 | ret.insert(ret.end(), input.begin(), input.end()); |
| 623 | } |
| 624 | } else { |
| 625 | // Otherwise invoke CScript::operator<<. |
| 626 | ret << input; |
| 627 | } |
| 628 | cnt++; |
| 629 | } (std::forward<Ts>(inputs)), ...); |
| 630 | |
| 631 | return ret; |
| 632 | } |
| 633 | |
| 634 | #endif // BITCOIN_SCRIPT_SCRIPT_H |
no test coverage detected