From d849a2d1fb5c38a719203c5a7b9ff8e6dc1e2e78 Mon Sep 17 00:00:00 2001 From: Kizarm <mrazik@volny.cz> Date: Wed, 21 Aug 2024 13:42:01 +0200 Subject: [PATCH] lambda in constructor --- V203/hello/morse.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/V203/hello/morse.cpp b/V203/hello/morse.cpp index e20c725..4803136 100644 --- a/V203/hello/morse.cpp +++ b/V203/hello/morse.cpp @@ -22,7 +22,8 @@ static constexpr unsigned slen (const char * const str) { while (str[n]) n++; return n; } -static constexpr unsigned char compress (const unsigned n) { +static const TABLE<unsigned char, array_size (morse_code)> compressed_table + ([](const unsigned n) -> auto { const char * const ptr = morse_code [n]; const unsigned len = slen (ptr); unsigned char mb = 0u; @@ -32,8 +33,7 @@ static constexpr unsigned char compress (const unsigned n) { if (ptr [n] == '-') mb |= (1u << n); } return mb; -} -static const TABLE<unsigned char, array_size (morse_code)> compressed_table (compress); +}); extern void print_morse_table (const TABLE<unsigned char, array_size(morse_code)> & tab); Morse::Morse(const GpioClass & pin, const unsigned int ms) noexcept : unit (ms), led (pin),