summaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorRoland Reichwein <mail@reichwein.it>2021-12-18 15:08:06 +0100
committerRoland Reichwein <mail@reichwein.it>2021-12-18 15:08:06 +0100
commite24a0d5d371d0916dbfb375d3ea404f7e6237c74 (patch)
tree44394489e193383f97c0856ce5e29a0e6d263738 /include
parent00ac8aad7ff3d0a82419b31cdeaa593d228c07d1 (diff)
Code cleanup
Diffstat (limited to 'include')
-rw-r--r--include/unicode.h10
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;