Add missing exception specs to basic_string and basic_string_view. Also implement some missing std functionality to them

This commit is contained in:
2022-07-20 19:13:21 -07:00
parent 2fe6f0b4e1
commit eafe6f5a21
6 changed files with 927 additions and 286 deletions

View File

@@ -174,7 +174,7 @@ namespace rexy{
}
template<BasicString T, class Char>
constexpr std::size_t find_first_of(T&& t, const Char* c, std::size_t start, std::size_t size){
constexpr std::size_t find_first_of(T&& t, const Char* c, std::size_t start, std::size_t size)noexcept{
if(start > t.length()){
return rexy::npos;
}
@@ -189,7 +189,27 @@ namespace rexy{
}
template<BasicString T, class Char>
constexpr std::size_t find_last_of(T&& t, const Char* c, std::size_t start, std::size_t size){
constexpr std::size_t find_first_not_of(T&& t, const Char* c, std::size_t start, std::size_t size)noexcept{
if(start > t.length()){
return rexy::npos;
}
for(auto it = t.cbegin() + start;it != t.cend();++it){
bool found = false;
for(std::size_t i = 0;i < size;++i){
if(*it == c[i]){
found = true;
break;
}
}
if(!found){
return it - t.cbegin();
}
}
return rexy::npos;
}
template<BasicString T, class Char>
constexpr std::size_t find_last_of(T&& t, const Char* c, std::size_t start, std::size_t size)noexcept{
if(start > t.length()){
return rexy::npos;
}
@@ -207,6 +227,31 @@ namespace rexy{
return rexy::npos;
}
template<BasicString T, class Char>
constexpr std::size_t find_last_not_of(T&& t, const Char* c, std::size_t start, std::size_t size)noexcept{
if(start > t.length()){
return rexy::npos;
}
const auto b = t.cend() - 1;
const auto e = t.cbegin() - 1 - start;
for(auto it = b;it != e;--it){
bool found = false;
for(std::size_t i = 0;i < size;++i){
if(*it == c[i]){
found = true;
break;
}
}
if(!found){
return it - t.cbegin();
}
}
return rexy::npos;
}
}
#endif