Remove iterators from string and string_view
Iterators could probably be implemented efficiently, but it is not a priority at the moment. They are removed for the time being.
This commit is contained in:
parent
ca8aae6c66
commit
b6746d7ac0
@ -2,7 +2,6 @@
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstring>
|
||||
#include <iterator>
|
||||
|
||||
#include "utility.hpp"
|
||||
#include "string_view.hpp"
|
||||
@ -24,11 +23,6 @@ protected:
|
||||
size_t m_capacity;
|
||||
|
||||
public:
|
||||
typedef char* iterator;
|
||||
typedef const char* const_iterator;
|
||||
typedef std::reverse_iterator<iterator> reverse_iterator;
|
||||
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
||||
|
||||
static constexpr const size_t npos = -1;
|
||||
|
||||
istring(char* _str, size_t _capacity, size_t _size);
|
||||
@ -78,24 +72,6 @@ public:
|
||||
const char* data() const;
|
||||
const char* c_str() const;
|
||||
|
||||
// Iterator functions
|
||||
|
||||
iterator begin();
|
||||
const_iterator begin() const;
|
||||
const_iterator cbegin() const;
|
||||
|
||||
iterator end();
|
||||
const_iterator end() const;
|
||||
const_iterator cend() const;
|
||||
|
||||
reverse_iterator rbegin();
|
||||
const_reverse_iterator rbegin() const;
|
||||
const_reverse_iterator crbegin() const;
|
||||
|
||||
reverse_iterator rend();
|
||||
const_reverse_iterator rend() const;
|
||||
const_reverse_iterator crend() const;
|
||||
|
||||
// Capacity
|
||||
|
||||
bool empty() const;
|
||||
@ -117,15 +93,8 @@ public:
|
||||
istring& insert(size_t index, const string_view& str);
|
||||
istring& insert(size_t index, const string_view& str, size_t str_index, size_t count = npos);
|
||||
istring& insert(size_t index, size_t count, char ch);
|
||||
iterator insert(const_iterator pos, char ch);
|
||||
iterator insert(const_iterator pos, size_t count, char ch);
|
||||
template <typename T>
|
||||
iterator insert(const_iterator pos, T first, T last) {
|
||||
}
|
||||
|
||||
istring& erase(size_t index = 0, size_t count = npos);
|
||||
iterator erase(const_iterator pos);
|
||||
iterator erase(const_iterator first, const_iterator last);
|
||||
|
||||
void push_back(char ch);
|
||||
void pop_back();
|
||||
@ -142,11 +111,7 @@ public:
|
||||
|
||||
istring& replace(size_t pos, size_t count, const string_view& str);
|
||||
istring& replace(size_t pos, size_t count, const string_view& str, size_t pos2, size_t count2 = npos);
|
||||
istring& replace(const_iterator first, const_iterator last, const string_view& str);
|
||||
istring& replace(size_t pos, size_t count, size_t count2, char ch);
|
||||
istring& replace(const_iterator first, const_iterator last, size_t count2, char ch);
|
||||
template <typename T>
|
||||
istring& replace(const_iterator first, const_iterator last, T first2, T last2);
|
||||
|
||||
/**
|
||||
* \brief Copy the string to a buffer
|
||||
|
||||
@ -3,7 +3,6 @@
|
||||
#include <cstddef>
|
||||
#include <cstring>
|
||||
#include <string> // std::char_traits
|
||||
#include <iterator>
|
||||
|
||||
namespace mtl {
|
||||
|
||||
@ -20,9 +19,6 @@ class string_view {
|
||||
friend class istring;
|
||||
|
||||
public:
|
||||
typedef const char* iterator;
|
||||
typedef std::reverse_iterator<iterator> reverse_iterator;
|
||||
|
||||
static constexpr size_t npos = -1;
|
||||
|
||||
constexpr string_view(const char* str) : m_str(str), m_size(std::char_traits<char>::length(str)) {}
|
||||
@ -39,18 +35,6 @@ public:
|
||||
constexpr const char* data() const { return m_str; }
|
||||
constexpr const char* c_str() const { return m_str; }
|
||||
|
||||
iterator begin() const { return m_str; }
|
||||
iterator cbegin() const { return m_str; }
|
||||
|
||||
iterator end() const { return m_str + m_size; }
|
||||
iterator cend() const { return m_str + m_size; }
|
||||
|
||||
reverse_iterator rbegin() const { return reverse_iterator(m_str + m_size); }
|
||||
reverse_iterator crbegin() const { return reverse_iterator(m_str + m_size); }
|
||||
|
||||
reverse_iterator rend() const { return reverse_iterator(m_str); }
|
||||
reverse_iterator crend() const { return reverse_iterator(m_str); }
|
||||
|
||||
constexpr bool empty() const { return m_size == 0; }
|
||||
|
||||
constexpr size_t size() const { return m_size; }
|
||||
|
||||
@ -124,50 +124,6 @@ const char* istring::c_str() const {
|
||||
return m_str;
|
||||
}
|
||||
|
||||
/*
|
||||
* ===== iterators =====
|
||||
*/
|
||||
|
||||
istring::iterator istring::begin() {
|
||||
return m_str;
|
||||
}
|
||||
istring::const_iterator istring::begin() const {
|
||||
return m_str;
|
||||
}
|
||||
istring::const_iterator istring::cbegin() const {
|
||||
return m_str;
|
||||
}
|
||||
|
||||
istring::iterator istring::end() {
|
||||
return m_str + m_size;
|
||||
}
|
||||
istring::const_iterator istring::end() const {
|
||||
return m_str + m_size;
|
||||
}
|
||||
istring::const_iterator istring::cend() const {
|
||||
return m_str + m_size;
|
||||
}
|
||||
|
||||
istring::reverse_iterator istring::rbegin() {
|
||||
return reverse_iterator(m_str + m_size);
|
||||
}
|
||||
istring::const_reverse_iterator istring::rbegin() const {
|
||||
return reverse_iterator(m_str + m_size);
|
||||
}
|
||||
istring::const_reverse_iterator istring::crbegin() const {
|
||||
return reverse_iterator(m_str + m_size);
|
||||
}
|
||||
|
||||
istring::reverse_iterator istring::rend() {
|
||||
return reverse_iterator(m_str);
|
||||
}
|
||||
istring::const_reverse_iterator istring::rend() const {
|
||||
return reverse_iterator(m_str);
|
||||
}
|
||||
istring::const_reverse_iterator istring::crend() const {
|
||||
return reverse_iterator(m_str);
|
||||
}
|
||||
|
||||
/*
|
||||
* ===== capacity =====
|
||||
*/
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user