@@ -348,14 +348,15 @@ namespace pcs // i.e. "pythonic c++ strings"
348348 }
349349
350350 /* * \brief Indexing operator. */
351- inline CppStringT operator [] (const key_type ch) noexcept
351+ inline value_type operator [] (const key_type ch) noexcept
352+ // inline CppStringT operator[] (const key_type ch) noexcept
352353 {
353354 auto it = m_table.find (ch);
354355 if (it != m_table.end ()) {
355356 return it->second ;
356357 }
357358 else {
358- return CppStringT (ch);
359+ return ch; // CppStringT(ch);
359360 }
360361 }
361362
@@ -366,7 +367,8 @@ namespace pcs // i.e. "pythonic c++ strings"
366367
367368 private:
368369 std::map<typename key_type, typename value_type> m_table{}; // the internal storage of the translation table. Access it via the indexing operator.
369- };
370+
371+ };
370372
371373
372374 // === Constructors / Destructor =======================
@@ -1774,24 +1776,14 @@ namespace pcs // i.e. "pythonic c++ strings"
17741776 * to be translated is not available as an entry in the tranlation
17751777 * table, it is set as is in the resulting string.
17761778 */
1777- CppStringT translate (const TransTable& table) const noexcept
1779+ CppStringT translate (TransTable& table) noexcept
17781780 {
1779- /*
17801781 CppStringT res{};
17811782 for (auto ch : *this ) {
17821783 try { res += table[ch]; }
17831784 catch (...) { res += ch; }
17841785 }
17851786 return res;
1786- */
1787-
1788- CppStringT res{};
1789- auto _translate = [&](auto const ch) {
1790- try { return table[ch]; }
1791- catch (...) { return ch; }
1792- };
1793- std::ranges::copy (std::views::transform (*this , _translate), std::back_inserter (res));
1794- return res;
17951787 }
17961788
17971789
0 commit comments