From 658598c4231b63a2bafd324de2b5030939dd7e36 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Tue, 28 Dec 2021 20:48:24 +0100 Subject: Minor simplifications --- include/unicode.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/include/unicode.h b/include/unicode.h index 8ac9f55..301f0db 100644 --- a/include/unicode.h +++ b/include/unicode.h @@ -204,7 +204,7 @@ namespace unicode::detail { template value_type get_code_unit() const noexcept { - if constexpr (std::is_same>::value) { + if constexpr (std::is_same_v>) { // std::list doesn't support it + n auto it{iterator}; std::advance(it, index); @@ -374,7 +374,7 @@ namespace unicode::detail { template inline void append(Args&&... args) { - if constexpr (std::is_same>::value) { + if constexpr (std::is_same_v>) { s.append({args...}); } else { (s.emplace_back(args), ...); @@ -390,10 +390,10 @@ namespace unicode::detail { append(byte_n_of_m<0,2>(value), byte_n_of_m<1,2>(value)); } else if (value < 0x10000) { // 3 bytes append(byte_n_of_m<0,3>(value), byte_n_of_m<1,3>(value), byte_n_of_m<2,3>(value)); - } else if (value < 0x110000) { // 4 bytes + } else { // 4 bytes + // expect value to be already valid Unicode values (checked in input iterator) append(byte_n_of_m<0,4>(value), byte_n_of_m<1,4>(value), byte_n_of_m<2,4>(value), byte_n_of_m<3,4>(value)); - } else - throw std::runtime_error("Invalid internal Unicode value: "s + std::to_string(static_cast(value))); + } } template = true> -- cgit v1.2.3