@@ -1065,13 +1065,15 @@ public:
1065
1065
basic_string (nullptr_t ) = delete;
1066
1066
#endif
1067
1067
1068
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20basic_string (const _CharT* __s, size_type __n) {
1068
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20basic_string (const _CharT* __s, size_type __n)
1069
+ _LIBCPP_DIAGNOSE_NULLPTR_IF(__n !=0 && __s ==nullptr ," if n is not zero" ) {
1069
1070
_LIBCPP_ASSERT_NON_NULL (__n ==0 || __s !=nullptr ," basic_string(const char*, n) detected nullptr" );
1070
1071
__init (__s, __n);
1071
1072
}
1072
1073
1073
1074
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1074
1075
basic_string (const _CharT* __s, size_type __n,const _Allocator& __a)
1076
+ _LIBCPP_DIAGNOSE_NULLPTR_IF (__n !=0 && __s ==nullptr ," if n is not zero" )
1075
1077
: __alloc_(__a) {
1076
1078
_LIBCPP_ASSERT_NON_NULL (__n ==0 || __s !=nullptr ," basic_string(const char*, n, allocator) detected nullptr" );
1077
1079
__init (__s, __n);
@@ -1394,7 +1396,8 @@ public:
1394
1396
return append (__sv.data () + __pos,std::min (__n, __sz - __pos));
1395
1397
}
1396
1398
1397
- _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&append (const value_type* __s, size_type __n);
1399
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&append (const value_type* __s, size_type __n)
1400
+ _LIBCPP_DIAGNOSE_NULLPTR_IF(__n !=0 && __s ==nullptr ," if n is not zero" );
1398
1401
_LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&append (const value_type* _LIBCPP_DIAGNOSE_NULLPTR __s);
1399
1402
_LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&append (size_type __n, value_type __c);
1400
1403
@@ -1521,8 +1524,9 @@ public:
1521
1524
return assign (__sv.data () + __pos,std::min (__n, __sz - __pos));
1522
1525
}
1523
1526
1524
- _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&assign (const value_type* __s, size_type __n);
1525
- _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&assign (const value_type* __s);
1527
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&assign (const value_type* __s, size_type __n)
1528
+ _LIBCPP_DIAGNOSE_NULLPTR_IF(__n !=0 && __s ==nullptr ," if n is not zero" );
1529
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&assign (const value_type* _LIBCPP_DIAGNOSE_NULLPTR __s);
1526
1530
_LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&assign (size_type __n, value_type __c);
1527
1531
1528
1532
template <class _InputIterator ,__enable_if_t <__has_exactly_input_iterator_category<_InputIterator>::value,int > =0 >
@@ -1593,7 +1597,8 @@ public:
1593
1597
1594
1598
_LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&
1595
1599
insert (size_type __pos1,const basic_string& __str, size_type __pos2, size_type __n = npos);
1596
- _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&insert (size_type __pos,const value_type* __s, size_type __n);
1600
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&insert (size_type __pos,const value_type* __s, size_type __n)
1601
+ _LIBCPP_DIAGNOSE_NULLPTR_IF(__n !=0 && __s ==nullptr ," if n is not zero" );
1597
1602
_LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&insert (size_type __pos,const value_type* _LIBCPP_DIAGNOSE_NULLPTR __s);
1598
1603
_LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&insert (size_type __pos, size_type __n, value_type __c);
1599
1604
_LIBCPP_CONSTEXPR_SINCE_CXX20 iteratorinsert (const_iterator __pos, value_type __c);
@@ -1673,8 +1678,10 @@ public:
1673
1678
}
1674
1679
1675
1680
_LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&
1676
- replace (size_type __pos, size_type __n1,const value_type* __s, size_type __n2);
1677
- _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&replace (size_type __pos, size_type __n1,const value_type* __s);
1681
+ replace (size_type __pos, size_type __n1,const value_type* __s, size_type __n2)
1682
+ _LIBCPP_DIAGNOSE_NULLPTR_IF (__n2 !=0 && __s ==nullptr ," if n2 is not zero" );
1683
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&
1684
+ replace (size_type __pos, size_type __n1,const value_type* _LIBCPP_DIAGNOSE_NULLPTR __s);
1678
1685
_LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&replace (size_type __pos, size_type __n1, size_type __n2, value_type __c);
1679
1686
1680
1687
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&
@@ -1783,7 +1790,8 @@ public:
1783
1790
return std::__str_find<value_type, size_type, traits_type, npos>(data (),size (), __sv.data (), __pos, __sv.size ());
1784
1791
}
1785
1792
1786
- _LIBCPP_CONSTEXPR_SINCE_CXX20 size_typefind (const value_type* __s, size_type __pos, size_type __n)const _NOEXCEPT {
1793
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 size_typefind (const value_type* __s, size_type __pos, size_type __n)const _NOEXCEPT
1794
+ _LIBCPP_DIAGNOSE_NULLPTR_IF(__n !=0 && __s ==nullptr ," if n is not zero" ) {
1787
1795
_LIBCPP_ASSERT_NON_NULL (__n ==0 || __s !=nullptr ," string::find(): received nullptr" );
1788
1796
return std::__str_find<value_type, size_type, traits_type, npos>(data (),size (), __s, __pos, __n);
1789
1797
}
@@ -1814,7 +1822,8 @@ public:
1814
1822
return std::__str_rfind<value_type, size_type, traits_type, npos>(data (),size (), __sv.data (), __pos, __sv.size ());
1815
1823
}
1816
1824
1817
- _LIBCPP_CONSTEXPR_SINCE_CXX20 size_typerfind (const value_type* __s, size_type __pos, size_type __n)const _NOEXCEPT {
1825
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 size_typerfind (const value_type* __s, size_type __pos, size_type __n)const _NOEXCEPT
1826
+ _LIBCPP_DIAGNOSE_NULLPTR_IF(__n !=0 && __s ==nullptr ," if n is not zero" ) {
1818
1827
_LIBCPP_ASSERT_NON_NULL (__n ==0 || __s !=nullptr ," string::rfind(): received nullptr" );
1819
1828
return std::__str_rfind<value_type, size_type, traits_type, npos>(data (),size (), __s, __pos, __n);
1820
1829
}
@@ -1847,7 +1856,8 @@ public:
1847
1856
}
1848
1857
1849
1858
_LIBCPP_CONSTEXPR_SINCE_CXX20 size_type
1850
- find_first_of (const value_type* __s, size_type __pos, size_type __n)const _NOEXCEPT {
1859
+ find_first_of (const value_type* __s, size_type __pos, size_type __n)const _NOEXCEPT
1860
+ _LIBCPP_DIAGNOSE_NULLPTR_IF (__n !=0 && __s ==nullptr ," if n is not zero" ) {
1851
1861
_LIBCPP_ASSERT_NON_NULL (__n ==0 || __s !=nullptr ," string::find_first_of(): received nullptr" );
1852
1862
return std::__str_find_first_of<value_type, size_type, traits_type, npos>(data (),size (), __s, __pos, __n);
1853
1863
}
@@ -1881,7 +1891,8 @@ public:
1881
1891
}
1882
1892
1883
1893
_LIBCPP_CONSTEXPR_SINCE_CXX20 size_type
1884
- find_last_of (const value_type* __s, size_type __pos, size_type __n)const _NOEXCEPT {
1894
+ find_last_of (const value_type* __s, size_type __pos, size_type __n)const _NOEXCEPT
1895
+ _LIBCPP_DIAGNOSE_NULLPTR_IF (__n !=0 && __s ==nullptr ," if n is not zero" ) {
1885
1896
_LIBCPP_ASSERT_NON_NULL (__n ==0 || __s !=nullptr ," string::find_last_of(): received nullptr" );
1886
1897
return std::__str_find_last_of<value_type, size_type, traits_type, npos>(data (),size (), __s, __pos, __n);
1887
1898
}
@@ -1915,7 +1926,8 @@ public:
1915
1926
}
1916
1927
1917
1928
_LIBCPP_CONSTEXPR_SINCE_CXX20 size_type
1918
- find_first_not_of (const value_type* __s, size_type __pos, size_type __n)const _NOEXCEPT {
1929
+ find_first_not_of (const value_type* __s, size_type __pos, size_type __n)const _NOEXCEPT
1930
+ _LIBCPP_DIAGNOSE_NULLPTR_IF (__n !=0 && __s ==nullptr ," if n is not zero" ) {
1919
1931
_LIBCPP_ASSERT_NON_NULL (__n ==0 || __s !=nullptr ," string::find_first_not_of(): received nullptr" );
1920
1932
return std::__str_find_first_not_of<value_type, size_type, traits_type, npos>(data (),size (), __s, __pos, __n);
1921
1933
}
@@ -1949,7 +1961,8 @@ public:
1949
1961
}
1950
1962
1951
1963
_LIBCPP_CONSTEXPR_SINCE_CXX20 size_type
1952
- find_last_not_of (const value_type* __s, size_type __pos, size_type __n)const _NOEXCEPT {
1964
+ find_last_not_of (const value_type* __s, size_type __pos, size_type __n)const _NOEXCEPT
1965
+ _LIBCPP_DIAGNOSE_NULLPTR_IF (__n !=0 && __s ==nullptr ," if n is not zero" ) {
1953
1966
_LIBCPP_ASSERT_NON_NULL (__n ==0 || __s !=nullptr ," string::find_last_not_of(): received nullptr" );
1954
1967
return std::__str_find_last_not_of<value_type, size_type, traits_type, npos>(data (),size (), __s, __pos, __n);
1955
1968
}
@@ -2026,7 +2039,8 @@ public:
2026
2039
}
2027
2040
2028
2041
_LIBCPP_CONSTEXPR_SINCE_CXX20int
2029
- compare (size_type __pos1, size_type __n1,const value_type* __s, size_type __n2)const ;
2042
+ compare (size_type __pos1, size_type __n1,const value_type* __s, size_type __n2)const
2043
+ _LIBCPP_DIAGNOSE_NULLPTR_IF (__n2 !=0 && __s ==nullptr ," if n2 is not zero" );
2030
2044
2031
2045
// starts_with
2032
2046
@@ -3564,7 +3578,8 @@ operator==(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
3564
3578
3565
3579
template <class _CharT ,class _Traits ,class _Allocator >
3566
3580
inline _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABIbool
3567
- operator ==(const basic_string<_CharT, _Traits, _Allocator>& __lhs,const _CharT* __rhs) _NOEXCEPT {
3581
+ operator ==(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
3582
+ const _CharT* _LIBCPP_DIAGNOSE_NULLPTR __rhs) _NOEXCEPT {
3568
3583
_LIBCPP_ASSERT_NON_NULL (__rhs !=nullptr ," operator==(basic_string, char*): received nullptr" );
3569
3584
3570
3585
using _String = basic_string<_CharT, _Traits, _Allocator>;