summaryrefslogtreecommitdiff
path: root/src/unicode.hh
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2017-04-23 12:47:26 +0100
committerMaxime Coste <mawww@kakoune.org>2017-04-23 12:47:26 +0100
commite264d189eb43710ee542b71ba845f8b44b693e12 (patch)
tree4ab61909cc91f677173d3453a22fde520edf00ee /src/unicode.hh
parentcaed8a55c7a5ac2754641769e1f603482886d5f1 (diff)
Add noexcept specifiers to unicode and utf8 functions
Diffstat (limited to 'src/unicode.hh')
-rw-r--r--src/unicode.hh26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/unicode.hh b/src/unicode.hh
index 98c69c30..eade3510 100644
--- a/src/unicode.hh
+++ b/src/unicode.hh
@@ -12,17 +12,17 @@ namespace Kakoune
using Codepoint = char32_t;
-inline bool is_eol(Codepoint c)
+inline bool is_eol(Codepoint c) noexcept
{
return c == '\n';
}
-inline bool is_horizontal_blank(Codepoint c)
+inline bool is_horizontal_blank(Codepoint c) noexcept
{
return c == ' ' or c == '\t';
}
-inline bool is_blank(Codepoint c)
+inline bool is_blank(Codepoint c) noexcept
{
return c == ' ' or c == '\t' or c == '\n';
}
@@ -30,28 +30,28 @@ inline bool is_blank(Codepoint c)
enum WordType { Word, WORD };
template<WordType word_type = Word>
-inline bool is_word(Codepoint c)
+inline bool is_word(Codepoint c) noexcept
{
return c == '_' or iswalnum((wchar_t)c);
}
template<>
-inline bool is_word<WORD>(Codepoint c)
+inline bool is_word<WORD>(Codepoint c) noexcept
{
return not is_blank(c);
}
-inline bool is_punctuation(Codepoint c)
+inline bool is_punctuation(Codepoint c) noexcept
{
return not (is_word(c) or is_blank(c));
}
-inline bool is_basic_alpha(Codepoint c)
+inline bool is_basic_alpha(Codepoint c) noexcept
{
return (c >= 'a' and c <= 'z') or (c >= 'A' and c <= 'Z');
}
-inline ColumnCount codepoint_width(Codepoint c)
+inline ColumnCount codepoint_width(Codepoint c) noexcept
{
return c == '\n' ? 1 : wcwidth((wchar_t)c);
}
@@ -65,7 +65,7 @@ enum class CharCategories
};
template<WordType word_type = Word>
-inline CharCategories categorize(Codepoint c)
+inline CharCategories categorize(Codepoint c) noexcept
{
if (is_eol(c))
return CharCategories::EndOfLine;
@@ -76,11 +76,11 @@ inline CharCategories categorize(Codepoint c)
return CharCategories::Punctuation;
}
-inline Codepoint to_lower(Codepoint cp) { return towlower((wchar_t)cp); }
-inline Codepoint to_upper(Codepoint cp) { return towupper((wchar_t)cp); }
+inline Codepoint to_lower(Codepoint cp) noexcept { return towlower((wchar_t)cp); }
+inline Codepoint to_upper(Codepoint cp) noexcept { return towupper((wchar_t)cp); }
-inline char to_lower(char c) { return c >= 'A' and c <= 'Z' ? c - 'A' + 'a' : c; }
-inline char to_upper(char c) { return c >= 'a' and c <= 'z' ? c - 'a' + 'A' : c; }
+inline char to_lower(char c) noexcept { return c >= 'A' and c <= 'Z' ? c - 'A' + 'a' : c; }
+inline char to_upper(char c) noexcept { return c >= 'a' and c <= 'z' ? c - 'a' + 'A' : c; }
}