Improve basic_string type to include more functionality of std::string. Also add option to disable SSO if so desired
This commit is contained in:
@@ -24,6 +24,8 @@
|
||||
#include <utility> //forward
|
||||
#include <type_traits> //{false,true}_type, declval, enable_if, remove_reference, decay
|
||||
|
||||
#include "../../utility.hpp" //strlen, strncmp
|
||||
|
||||
namespace rexy{
|
||||
|
||||
#define REXY_HAS_MEMFUN_WITH_RET(type, ret, fun, ...) \
|
||||
@@ -92,31 +94,29 @@ namespace rexy{
|
||||
if(left.length() != right.length()){
|
||||
return false;
|
||||
}
|
||||
return !detail::string_compare(std::forward<Str1>(left), std::forward<Str2>(right), left.length());
|
||||
return !rexy::strncmp(left.c_str(), right.c_str(), left.length()+1);
|
||||
}
|
||||
template<class Str1, std::enable_if_t<are_strings<Str1>::value,int> = 0>
|
||||
constexpr bool operator==(Str1&& left, typename std::decay_t<Str1>::const_pointer right){
|
||||
if(right == nullptr){
|
||||
return false;
|
||||
}
|
||||
const auto rlen = detail::string_len(right);
|
||||
const auto rlen = rexy::strlen(right);
|
||||
if(rlen != left.length()){
|
||||
return false;
|
||||
}
|
||||
const auto minlen = min(left.length(), rlen);
|
||||
return !detail::string_compare(left.c_str(), right, minlen+1);
|
||||
return !rexy::strncmp(left.c_str(), right, rlen+1);
|
||||
}
|
||||
template<class Str1, std::enable_if_t<are_strings<Str1>::value,int> = 0>
|
||||
constexpr bool operator==(typename std::decay_t<Str1>::const_pointer left, Str1&& right){
|
||||
if(left == nullptr){
|
||||
return false;
|
||||
}
|
||||
const auto llen = detail::string_len(left);
|
||||
const auto llen = rexy::strlen(left);
|
||||
if(llen != right.length()){
|
||||
return false;
|
||||
}
|
||||
const auto minlen = min(right.length(), llen);
|
||||
return !detail::string_compare(right.c_str(), left, minlen+1);
|
||||
return !rexy::strncmp(left, right.c_str(), llen+1);
|
||||
}
|
||||
template<class Str1, class Str2, std::enable_if_t<are_strings<Str1, Str2>::value,int> = 0>
|
||||
constexpr bool operator!=(Str1&& left, Str2&& right)noexcept{
|
||||
|
||||
Reference in New Issue
Block a user