util/StringPointer: rename typedef pointer to pointer_type

This commit is contained in:
Max Kellermann
2016-04-12 22:49:03 +02:00
parent fd5d42836f
commit 9b85446808
17 changed files with 116 additions and 111 deletions

View File

@@ -44,15 +44,15 @@ template<typename T=char>
class AllocatedString {
public:
typedef typename StringPointer<T>::value_type value_type;
typedef typename StringPointer<T>::pointer pointer;
typedef typename StringPointer<T>::const_pointer const_pointer;
typedef typename StringPointer<T>::pointer_type pointer_type;
typedef typename StringPointer<T>::const_pointer_type const_pointer_type;
static constexpr value_type SENTINEL = '\0';
private:
pointer value;
pointer_type value;
explicit AllocatedString(pointer _value)
explicit AllocatedString(pointer_type _value)
:value(_value) {}
public:
@@ -65,7 +65,7 @@ public:
delete[] value;
}
static AllocatedString Donate(pointer value) {
static AllocatedString Donate(pointer_type value) {
return AllocatedString(value);
}
@@ -79,16 +79,16 @@ public:
return Donate(p);
}
static AllocatedString Duplicate(const_pointer src);
static AllocatedString Duplicate(const_pointer_type src);
static AllocatedString Duplicate(const_pointer begin,
const_pointer end) {
static AllocatedString Duplicate(const_pointer_type begin,
const_pointer_type end) {
auto p = new value_type[end - begin + 1];
*std::copy(begin, end, p) = SENTINEL;
return Donate(p);
}
static AllocatedString Duplicate(const_pointer begin,
static AllocatedString Duplicate(const_pointer_type begin,
size_t length) {
auto p = new value_type[length + 1];
*std::copy_n(begin, length, p) = SENTINEL;
@@ -104,7 +104,7 @@ public:
return value == nullptr;
}
constexpr const_pointer c_str() const {
constexpr const_pointer_type c_str() const {
return value;
}
@@ -112,8 +112,8 @@ public:
return *value == SENTINEL;
}
pointer Steal() {
pointer result = value;
pointer_type Steal() {
pointer_type result = value;
value = nullptr;
return result;
}