Add iterators to cx/string and fix including null terminator in length when created from an array
This commit is contained in:
parent
588835d80a
commit
d5a0f1927d
@ -69,6 +69,9 @@ namespace rexy::cx{
|
||||
for(size_type i = 0;i < M;++i){
|
||||
m_data[i] = data[i];
|
||||
}
|
||||
if(m_data[m_length - 1] == 0){
|
||||
--m_length; //exclude null terminator in length
|
||||
}
|
||||
}
|
||||
constexpr string(const_pointer data)noexcept:
|
||||
m_length(rexy::strlen(data))
|
||||
@ -132,6 +135,19 @@ namespace rexy::cx{
|
||||
constexpr operator const_pointer(void)const noexcept
|
||||
{return m_data;}
|
||||
|
||||
constexpr iterator begin(void)noexcept
|
||||
{return m_data;}
|
||||
constexpr const_iterator begin(void)const noexcept
|
||||
{return m_data;}
|
||||
constexpr const_iterator cbegin(void)const noexcept
|
||||
{return m_data;}
|
||||
constexpr iterator end(void)noexcept
|
||||
{return m_data+m_length;}
|
||||
constexpr const_iterator end(void)const noexcept
|
||||
{return m_data+m_length;}
|
||||
constexpr const_iterator cend(void)const noexcept
|
||||
{return m_data+m_length;}
|
||||
|
||||
constexpr bool valid(void)const noexcept
|
||||
{return m_length > 0;}
|
||||
constexpr reference operator[](size_type i)noexcept
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user