Skip to content

Commit cd67ebe

Browse files
committed
Style, add deduction guide.
1 parent abe7bd9 commit cd67ebe

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

include/bitcoin/system/types.hpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -186,21 +186,27 @@ template <size_t Size>
186186
class text_t
187187
{
188188
public:
189-
std::array<uint8_t, Size - 1> data;
190189
CONSTEVAL text_t(const char (&string)[Size]) noexcept
191-
: data(to_array(string)) {}
190+
: data(to_array(string))
191+
{
192+
}
193+
194+
const std::array<uint8_t, Size - 1> data;
192195

193196
private:
194197
static CONSTEVAL auto to_array(const char(&string)[Size]) noexcept
195198
{
196-
std::array<uint8_t, Size - 1> data{};
197-
for (size_t index = 0; index < Size - 1; ++index)
198-
data.at(index) = string[index];
199+
std::array<uint8_t, Size - 1> out{};
200+
for (size_t index{}; index < Size - 1; ++index)
201+
out[index] = string[index];
199202

200-
return data;
203+
return out;
201204
}
202205
};
203206

207+
template <size_t Size>
208+
text_t(const char(&)[Size]) noexcept -> text_t<Size>;
209+
204210
template <size_t Size, typename Byte,
205211
std::enable_if_t<std::is_same_v<Byte, char>, bool> = true>
206212
constexpr size_t literal_length(const Byte(&)[Size]) noexcept

0 commit comments

Comments
 (0)