|
|
@ -19,7 +19,7 @@ namespace gp { |
|
|
|
{ |
|
|
|
T* data; /**< the only data field of the class */ |
|
|
|
typedef T value_type; /**< The type of which a reference will be returned on dereferencing */ |
|
|
|
typedef std::size_t difference_type; /**< The type of the substraction of two pointers */ |
|
|
|
typedef std::intptr_t difference_type; /**< The type of the substraction of two pointers */ |
|
|
|
static constexpr iterator_type_t iterator_type = iterator_type_t::contiguous_iterator; /**< @see iterator_type_t */ |
|
|
|
|
|
|
|
/**
|
|
|
@ -81,6 +81,11 @@ namespace gp { |
|
|
|
return pointer_iterator{data+sign*offset}; |
|
|
|
} |
|
|
|
|
|
|
|
constexpr pointer_iterator operator+(const difference_type offset) const |
|
|
|
{ |
|
|
|
return pointer_iterator{data+sign*offset}; |
|
|
|
} |
|
|
|
|
|
|
|
constexpr pointer_iterator operator+(const int offset) const |
|
|
|
{ |
|
|
|
return pointer_iterator{data+sign*offset}; |
|
|
@ -91,6 +96,11 @@ namespace gp { |
|
|
|
return pointer_iterator{data-sign*offset}; |
|
|
|
} |
|
|
|
|
|
|
|
constexpr pointer_iterator operator-(const difference_type offset) const |
|
|
|
{ |
|
|
|
return pointer_iterator{data-sign*offset}; |
|
|
|
} |
|
|
|
|
|
|
|
constexpr pointer_iterator operator-(const int offset) const |
|
|
|
{ |
|
|
|
return pointer_iterator{data-sign*offset}; |
|
|
@ -98,7 +108,7 @@ namespace gp { |
|
|
|
|
|
|
|
constexpr difference_type operator-(const pointer_iterator& oth) const |
|
|
|
{ |
|
|
|
return (p">(T*)data-(T*)oth.data)*sign; |
|
|
|
return (data-oth.data)*sign; |
|
|
|
} |
|
|
|
|
|
|
|
constexpr bool operator==(const pointer_iterator oth) const |
|
|
@ -116,10 +126,20 @@ namespace gp { |
|
|
|
return reinterpret_cast<std::intptr_t>(data) <= reinterpret_cast<std::intptr_t>(oth.data); |
|
|
|
} |
|
|
|
|
|
|
|
constexpr bool after_or_equal(const pointer_iterator oth) const |
|
|
|
{ |
|
|
|
return reinterpret_cast<std::intptr_t>(data) >= reinterpret_cast<std::intptr_t>(oth.data); |
|
|
|
} |
|
|
|
|
|
|
|
constexpr bool operator<=(const pointer_iterator oth) const |
|
|
|
{ |
|
|
|
return before_or_equal(oth); |
|
|
|
} |
|
|
|
|
|
|
|
constexpr bool operator>=(const pointer_iterator oth) const |
|
|
|
{ |
|
|
|
return after_or_equal(oth); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
/**
|
|
|
@ -134,7 +154,7 @@ namespace gp { |
|
|
|
{ |
|
|
|
const T* data; /**< @see pointer_iterator */ |
|
|
|
typedef T value_type; /**< @see pointer_iterator */ |
|
|
|
typedef std::size_t difference_type; /**< @see pointer_iterator */ |
|
|
|
typedef std::intptr_t difference_type; /**< @see pointer_iterator */ |
|
|
|
static constexpr iterator_type_t iterator_type = iterator_type_t::contiguous_iterator; /**< @see pointer_iterator */ |
|
|
|
|
|
|
|
constexpr const_pointer_iterator(const const_pointer_iterator& oth) |
|
|
@ -187,11 +207,21 @@ namespace gp { |
|
|
|
return const_pointer_iterator{data+sign*offset}; |
|
|
|
} |
|
|
|
|
|
|
|
constexpr const_pointer_iterator operator+(const difference_type offset) const |
|
|
|
{ |
|
|
|
return const_pointer_iterator{data+sign*offset}; |
|
|
|
} |
|
|
|
|
|
|
|
constexpr const_pointer_iterator operator+(const int offset) const |
|
|
|
{ |
|
|
|
return const_pointer_iterator{data+sign*offset}; |
|
|
|
} |
|
|
|
|
|
|
|
constexpr const_pointer_iterator operator-(const difference_type offset) const |
|
|
|
{ |
|
|
|
return const_pointer_iterator{data-sign*offset}; |
|
|
|
} |
|
|
|
|
|
|
|
constexpr const_pointer_iterator operator-(const std::size_t offset) const |
|
|
|
{ |
|
|
|
return const_pointer_iterator{data-sign*offset}; |
|
|
@ -222,9 +252,19 @@ namespace gp { |
|
|
|
return reinterpret_cast<std::intptr_t>(data) <= reinterpret_cast<std::intptr_t>(oth.data); |
|
|
|
} |
|
|
|
|
|
|
|
constexpr bool after_or_equal(const const_pointer_iterator oth) const |
|
|
|
{ |
|
|
|
return reinterpret_cast<std::intptr_t>(data) >= reinterpret_cast<std::intptr_t>(oth.data); |
|
|
|
} |
|
|
|
|
|
|
|
constexpr bool operator<=(const const_pointer_iterator oth) const |
|
|
|
{ |
|
|
|
return before_or_equal(oth); |
|
|
|
} |
|
|
|
|
|
|
|
constexpr bool operator>=(const const_pointer_iterator oth) const |
|
|
|
{ |
|
|
|
return after_or_equal(oth); |
|
|
|
} |
|
|
|
}; |
|
|
|
} |