mirror of
https://github.com/Z3Prover/z3
synced 2025-04-23 17:15:31 +00:00
Add dll_elements
This commit is contained in:
parent
edbe1087e3
commit
305943a091
1 changed files with 18 additions and 9 deletions
|
@ -188,14 +188,14 @@ class dll_iterator {
|
|||
dll_iterator(T const* elem, bool first): m_elem(elem), m_first(first) { }
|
||||
|
||||
public:
|
||||
static dll_iterator mk_begin(T const* elem) {
|
||||
// Setting first==(bool)elem makes this also work for elem==nullptr;
|
||||
static dll_iterator mk_begin(T const* list) {
|
||||
// Setting first==(bool)list makes this also work for list==nullptr;
|
||||
// but we can't implement top-level begin/end for pointers because it clashes with the definition for arrays.
|
||||
return {elem, (bool)elem};
|
||||
return {list, (bool)list};
|
||||
}
|
||||
|
||||
static dll_iterator mk_end(T const* elem) {
|
||||
return {elem, false};
|
||||
static dll_iterator mk_end(T const* list) {
|
||||
return {list, false};
|
||||
}
|
||||
|
||||
using value_type = T;
|
||||
|
@ -226,14 +226,23 @@ public:
|
|||
template < typename T
|
||||
, typename U = std::enable_if_t<std::is_base_of_v<dll_base<T>, T>> // should only match if T actually inherits from dll_base<T>
|
||||
>
|
||||
dll_iterator<T> begin(T const& elem) {
|
||||
return dll_iterator<T>::mk_begin(&elem);
|
||||
dll_iterator<T> begin(T const& list) {
|
||||
return dll_iterator<T>::mk_begin(&list);
|
||||
}
|
||||
|
||||
template < typename T
|
||||
, typename U = std::enable_if_t<std::is_base_of_v<dll_base<T>, T>> // should only match if T actually inherits from dll_base<T>
|
||||
>
|
||||
dll_iterator<T> end(T const& elem)
|
||||
dll_iterator<T> end(T const& list)
|
||||
{
|
||||
return dll_iterator<T>::mk_end(&elem);
|
||||
return dll_iterator<T>::mk_end(&list);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
class dll_elements {
|
||||
T const* m_list;
|
||||
public:
|
||||
dll_elements(T const* list): m_list(list) {}
|
||||
dll_iterator<T> begin() const { return dll_iterator<T>::mk_begin(m_list); }
|
||||
dll_iterator<T> end() const { return dll_iterator<T>::mk_end(m_list); }
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue