Update cx::string to be more level with string_view
This commit is contained in:
@@ -201,6 +201,40 @@ namespace rexy{
|
||||
return l = (l + r);
|
||||
}
|
||||
|
||||
template<class T, class Char, std::enable_if_t<is_string<T>::value, int> = 0>
|
||||
constexpr std::size_t find_first_of(T&& t, const Char* c, std::size_t start, std::size_t size){
|
||||
if(start > t.length()){
|
||||
return rexy::npos;
|
||||
}
|
||||
for(auto it = t.cbegin() + start;it != t.cend();++it){
|
||||
for(std::size_t i = 0;i < size;++i){
|
||||
if(*it == c[i]){
|
||||
return it - t.cbegin();
|
||||
}
|
||||
}
|
||||
}
|
||||
return rexy::npos;
|
||||
}
|
||||
|
||||
template<class T, class Char, std::enable_if_t<is_string<T>::value, int> = 0>
|
||||
constexpr std::size_t find_last_of(T&& t, const Char* c, std::size_t start, std::size_t size){
|
||||
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){
|
||||
for(std::size_t i = 0;i < size;++i){
|
||||
if(*it == c[i]){
|
||||
return it - t.cbegin();
|
||||
}
|
||||
}
|
||||
}
|
||||
return rexy::npos;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user