diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/unicode.h | 10 | 
1 files changed, 5 insertions, 5 deletions
| diff --git a/include/unicode.h b/include/unicode.h index 277c4de..6b6f21a 100644 --- a/include/unicode.h +++ b/include/unicode.h @@ -199,14 +199,14 @@ namespace unicode::detail {    // set value member    void calculate_value()    { +   static_assert(sizeof(T) == 1 || sizeof(T) == 2 || sizeof(T) == 4); +     if constexpr(sizeof(T) == 1) {      calculate_value_utf8();     } else if constexpr (sizeof(T) == 2) {      calculate_value_utf16();     } else if constexpr (sizeof(T) == 4) {      calculate_value_utf32(); -   } else { -    throw std::runtime_error("Invalid character size: "s + std::to_string(sizeof(T)));     }    } @@ -334,14 +334,14 @@ namespace unicode::detail {    reference operator=(const char32_t& value)    { +   static_assert(sizeof(T) == 1 || sizeof(T) == 2 || sizeof(T) == 4); +     if constexpr(sizeof(T) == 1) {      append_utf8(value);     } else if constexpr(sizeof(T) == 2) {      append_utf16(value);     } else if constexpr(sizeof(T) == 4) {      append_utf32(value); -   } else { -    throw std::runtime_error("Invalid type size: "s + std::to_string(sizeof(T)));     }     return *this;    } @@ -473,7 +473,7 @@ namespace unicode {     }     if (value > 255) -    throw std::invalid_argument("Bad Unicode value above 255: "s + std::to_string(static_cast<uint32_t>(value))); +    throw std::invalid_argument("Bad ISO 8859 value above 255: "s + std::to_string(static_cast<uint32_t>(value)));     s.push_back(static_cast<typename iso_back_insert_iterator::value_type>(value));     return *this; | 
