starts_with(_CharT __x) const noexcept
{ return __sv_type(this->data(), this->size()).starts_with(__x); }
+ [[__gnu__::__nonnull__]]
constexpr bool
starts_with(const _CharT* __x) const noexcept
{ return __sv_type(this->data(), this->size()).starts_with(__x); }
ends_with(_CharT __x) const noexcept
{ return __sv_type(this->data(), this->size()).ends_with(__x); }
+ [[__gnu__::__nonnull__]]
constexpr bool
ends_with(const _CharT* __x) const noexcept
{ return __sv_type(this->data(), this->size()).ends_with(__x); }
contains(_CharT __x) const noexcept
{ return __sv_type(this->data(), this->size()).contains(__x); }
+ [[__gnu__::__nonnull__]]
constexpr bool
contains(const _CharT* __x) const noexcept
{ return __sv_type(this->data(), this->size()).contains(__x); }
starts_with(_CharT __x) const noexcept
{ return __sv_type(this->data(), this->size()).starts_with(__x); }
+ [[__gnu__::__nonnull__]]
bool
starts_with(const _CharT* __x) const noexcept
{ return __sv_type(this->data(), this->size()).starts_with(__x); }
ends_with(_CharT __x) const noexcept
{ return __sv_type(this->data(), this->size()).ends_with(__x); }
+ [[__gnu__::__nonnull__]]
bool
ends_with(const _CharT* __x) const noexcept
{ return __sv_type(this->data(), this->size()).ends_with(__x); }
contains(_CharT __x) const noexcept
{ return __sv_type(this->data(), this->size()).contains(__x); }
+ [[__gnu__::__nonnull__]]
bool
contains(const _CharT* __x) const noexcept
{ return __sv_type(this->data(), this->size()).contains(__x); }
starts_with(_CharT __x) const noexcept
{ return !this->empty() && traits_type::eq(this->front(), __x); }
+ [[__gnu__::__nonnull__]]
constexpr bool
starts_with(const _CharT* __x) const noexcept
{ return this->starts_with(basic_string_view(__x)); }
ends_with(_CharT __x) const noexcept
{ return !this->empty() && traits_type::eq(this->back(), __x); }
+ [[__gnu__::__nonnull__]]
constexpr bool
ends_with(const _CharT* __x) const noexcept
{ return this->ends_with(basic_string_view(__x)); }
contains(_CharT __x) const noexcept
{ return this->find(__x) != npos; }
+ [[__gnu__::__nonnull__]]
constexpr bool
contains(const _CharT* __x) const noexcept
{ return this->find(__x) != npos; }
--- /dev/null
+// { dg-options "-std=gnu++23 -Wnonnull -O0" }
+// { dg-do compile { target c++23 } }
+
+#include <string>
+
+void
+test01(const std::string& s)
+{
+ s.contains((const char*)nullptr); // { dg-warning "\\\[-Wnonnull" }
+ s.contains((char*)nullptr); // { dg-warning "\\\[-Wnonnull" }
+ s.contains(nullptr); // { dg-warning "\\\[-Wnonnull" }
+}
--- /dev/null
+// { dg-options "-std=gnu++20 -Wnonnull -O0" }
+// { dg-do compile { target c++20 } }
+
+#include <string>
+
+void
+test01(const std::string& s)
+{
+ s.ends_with((const char*)nullptr); // { dg-warning "\\\[-Wnonnull" }
+ s.ends_with((char*)nullptr); // { dg-warning "\\\[-Wnonnull" }
+ s.ends_with(nullptr); // { dg-warning "\\\[-Wnonnull" }
+}
--- /dev/null
+// { dg-options "-std=gnu++20 -Wnonnull -O0" }
+// { dg-do compile { target c++20 } }
+
+#include <string>
+
+void
+test01(const std::string& s)
+{
+ s.starts_with((const char*)nullptr); // { dg-warning "\\\[-Wnonnull" }
+ s.starts_with((char*)nullptr); // { dg-warning "\\\[-Wnonnull" }
+ s.starts_with(nullptr); // { dg-warning "\\\[-Wnonnull" }
+}
--- /dev/null
+// { dg-options "-std=gnu++23 -Wnonnull -O0" }
+// { dg-do compile { target c++23 } }
+
+#include <string_view>
+
+void
+test01(std::string_view s)
+{
+ s.contains((const char*)nullptr); // { dg-warning "\\\[-Wnonnull" }
+ s.contains((char*)nullptr); // { dg-warning "\\\[-Wnonnull" }
+ s.contains(nullptr); // { dg-warning "\\\[-Wnonnull" }
+}
--- /dev/null
+// { dg-options "-std=gnu++20 -Wnonnull -O0" }
+// { dg-do compile { target c++20 } }
+
+#include <string_view>
+
+void
+test01(std::string_view s)
+{
+ s.ends_with((const char*)nullptr); // { dg-warning "\\\[-Wnonnull" }
+ s.ends_with((char*)nullptr); // { dg-warning "\\\[-Wnonnull" }
+ s.ends_with(nullptr); // { dg-warning "\\\[-Wnonnull" }
+}
--- /dev/null
+// { dg-options "-std=gnu++20 -Wnonnull -O0" }
+// { dg-do compile { target c++20 } }
+
+#include <string_view>
+
+void
+test01(std::string_view s)
+{
+ s.starts_with((const char*)nullptr); // { dg-warning "\\\[-Wnonnull" }
+ s.starts_with((char*)nullptr); // { dg-warning "\\\[-Wnonnull" }
+ s.starts_with(nullptr); // { dg-warning "\\\[-Wnonnull" }
+}