Skip to content

Commit fa39cdd

Browse files
author
MarcoFalke
committed
refactor: Use C++17 std::array deduction for OUTPUT_TYPES
1 parent 2dab2d2 commit fa39cdd

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/outputtype.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ static const std::string OUTPUT_TYPE_STRING_LEGACY = "legacy";
1919
static const std::string OUTPUT_TYPE_STRING_P2SH_SEGWIT = "p2sh-segwit";
2020
static const std::string OUTPUT_TYPE_STRING_BECH32 = "bech32";
2121

22-
const std::array<OutputType, 3> OUTPUT_TYPES = {OutputType::LEGACY, OutputType::P2SH_SEGWIT, OutputType::BECH32};
23-
2422
bool ParseOutputType(const std::string& type, OutputType& output_type)
2523
{
2624
if (type == OUTPUT_TYPE_STRING_LEGACY) {

src/outputtype.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@ enum class OutputType {
2020
BECH32,
2121
};
2222

23-
extern const std::array<OutputType, 3> OUTPUT_TYPES;
23+
static constexpr auto OUTPUT_TYPES = std::array{
24+
OutputType::LEGACY,
25+
OutputType::P2SH_SEGWIT,
26+
OutputType::BECH32,
27+
};
2428

2529
[[nodiscard]] bool ParseOutputType(const std::string& str, OutputType& output_type);
2630
const std::string& FormatOutputType(OutputType type);

0 commit comments

Comments
 (0)