diff --git a/ostd/string.hh b/ostd/string.hh index 9acfc65..1133225 100644 --- a/ostd/string.hh +++ b/ostd/string.hh @@ -31,14 +31,7 @@ private: public: CharRangeBase(): p_beg(nullptr), p_end(nullptr) {}; - - template - CharRangeBase(T *beg, U end, std::enable_if_t< - (std::is_pointer_v || std::is_null_pointer_v) && - std::is_convertible_v, Nat - > = Nat()): p_beg(beg), p_end(end) {} - - CharRangeBase(T *beg, size_t n): p_beg(beg), p_end(beg + n) {} + CharRangeBase(T *beg, T *end): p_beg(beg), p_end(end) {} /* TODO: traits for utf-16/utf-32 string lengths, for now assume char */ template @@ -57,10 +50,8 @@ public: p_beg(beg), p_end(beg + N - (beg[N - 1] == '\0')) {} - template - CharRangeBase(std::basic_string const &s, std::enable_if_t< - std::is_convertible_v, Nat - > = Nat()): + template + CharRangeBase(std::basic_string, TR, A> const &s): p_beg(s.data()), p_end(s.data() + s.size()) {} @@ -256,14 +247,14 @@ inline bool starts_with(ConstCharRange a, ConstCharRange b) { template struct ranged_traits> { static CharRangeBase iter(std::basic_string &v) { - return CharRangeBase{v.data(), v.size()}; + return CharRangeBase{v.data(), v.data() + v.size()}; } }; template struct ranged_traits const> { static CharRangeBase iter(std::basic_string const &v) { - return CharRangeBase{v.data(), v.size()}; + return CharRangeBase{v.data(), v.data() + v.size()}; } }; @@ -305,7 +296,7 @@ inline std::basic_string>, TR, A> make_string( inline namespace literals { inline namespace string_literals { inline ConstCharRange operator "" _sr(char const *str, size_t len) { - return ConstCharRange(str, len); + return ConstCharRange(str, str + len); } } }