return _mStr[i];
}
+ bool startsWith(const CStringView prefix) const noexcept
+ {
+ BT_ASSERT_DBG(_mStr);
+ BT_ASSERT_DBG(prefix);
+ return std::strncmp(_mStr, prefix, prefix.len()) == 0;
+ }
+
private:
const char *_mStr = nullptr;
};
*
* Both `lhs` and `rhs` must not have an underlying `nullptr` raw data.
*/
-template <typename LhsT, typename RhsT>
+template <
+ typename LhsT, typename RhsT,
+ typename = typename std::enable_if<internal::ComparableWithCStringView<LhsT>::value>::type,
+ typename = typename std::enable_if<internal::ComparableWithCStringView<RhsT>::value>::type>
bool operator!=(LhsT&& lhs, RhsT&& rhs) noexcept
{
return !(std::forward<LhsT>(lhs) == std::forward<RhsT>(rhs));
} /* namespace bt2c */
+/*
+ * Appends `rhs` to `lhs`.
+ */
+inline void operator+=(std::string& lhs, bt2c::CStringView rhs)
+{
+ lhs += rhs.data();
+}
+
#endif /* BABELTRACE_CPP_COMMON_BT2C_C_STRING_VIEW_HPP */