summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib/netlist/plib/pstring.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/netlist/plib/pstring.h')
-rw-r--r--src/lib/netlist/plib/pstring.h19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/lib/netlist/plib/pstring.h b/src/lib/netlist/plib/pstring.h
index 4a9d99300bb..86b041cadaf 100644
--- a/src/lib/netlist/plib/pstring.h
+++ b/src/lib/netlist/plib/pstring.h
@@ -111,7 +111,7 @@ public:
template<typename C, std::size_t N,
class = typename std::enable_if<std::is_same<C, const mem_t>::value>::type>
- pstring_t(C (&string)[N]) // NOLINT(cppcoreguidelines-avoid-c-arrays, modernize-avoid-c-arrays)
+ pstring_t(C (&string)[N]) noexcept(false) // NOLINT(cppcoreguidelines-avoid-c-arrays, modernize-avoid-c-arrays)
{
static_assert(N > 0,"pstring from array of length 0");
// need std::exception since pexception depends on pstring
@@ -174,7 +174,7 @@ public:
size_type length() const noexcept { return traits_type::len(m_str); }
size_type size() const noexcept { return traits_type::len(m_str); }
- bool empty() const noexcept { return m_str.size() == 0; }
+ bool empty() const noexcept { return m_str.empty(); }
pstring_t substr(size_type start, size_type nlen = npos) const;
int compare(const pstring_t &right) const noexcept;
@@ -186,8 +186,8 @@ public:
pstring_t& operator+=(const pstring_t &string) { m_str.append(string.m_str); return *this; }
pstring_t& operator+=(const code_t c) { traits_type::encode(c, m_str); return *this; }
friend pstring_t operator+(const pstring_t &lhs, const pstring_t &rhs) { return pstring_t(lhs) += rhs; }
- friend pstring_t operator+(const pstring_t &lhs, const code_t rhs) { return pstring_t(lhs) += rhs; }
- friend pstring_t operator+(const code_t lhs, const pstring_t &rhs) { return pstring_t(1, lhs) += rhs; }
+ friend pstring_t operator+(const pstring_t &lhs, code_t rhs) { return pstring_t(lhs) += rhs; }
+ friend pstring_t operator+(code_t lhs, const pstring_t &rhs) { return pstring_t(1, lhs) += rhs; }
// comparison operators
bool operator==(const pstring_t &string) const noexcept { return (compare(string) == 0); }
@@ -317,7 +317,9 @@ struct putf8_traits
const mem_t *p1 = p;
std::size_t i = n;
while (i-- > 0)
+ {
p1 += codelen(p1);
+ }
return p1;
}
};
@@ -336,7 +338,9 @@ struct putf16_traits
// FIXME: check that size is equal
auto c = static_cast<uint16_t>(*i++);
if (!((c & 0xd800) == 0xd800))
+ {
ret++;
+ }
}
return ret;
}
@@ -347,10 +351,7 @@ struct putf16_traits
}
static std::size_t codelen(const code_t c) noexcept
{
- if (c < 0x10000)
- return 1;
- else // U+10000 U+1FFFFF
- return 2;
+ return (c < 0x10000) ? 1 : 2; // U+10000 U+1FFFFF
}
static code_t code(const mem_t *p) noexcept
{
@@ -381,7 +382,9 @@ struct putf16_traits
{
std::size_t i = n;
while (i-- > 0)
+ {
p += codelen(p);
+ }
return p;
}
};