Trying to fix the build, still broken

This commit is contained in:
King_DuckZ 2025-02-25 00:21:37 +00:00
parent bc12725ff2
commit 1224886848
No known key found for this signature in database
GPG key ID: E722F211F3A9B020
3 changed files with 143 additions and 132 deletions

View file

@ -52,9 +52,9 @@ struct uninitialized_any_iterator : std::logic_error {
template<typename ValueType> struct any_input_iterator;
template<typename ValueType> struct any_output_iterator;
template<typename ValueType, typename Reference> struct any_forward_iterator;
template<typename ValueType> struct any_bidirectional_iterator;
template<typename ValueType> struct any_random_access_iterator;
template<typename ValueType, typename Reference, typename Pointer> struct any_forward_iterator;
template<typename ValueType, typename Reference, typename Pointer> struct any_bidirectional_iterator;
template<typename ValueType, typename Reference, typename Pointer> struct any_random_access_iterator;
template<typename It>
@ -66,14 +66,14 @@ struct is_any_iterator<any_input_iterator<ValueType>> { static constexpr bool va
template<typename ValueType>
struct is_any_iterator<any_output_iterator<ValueType>> { static constexpr bool value = true; };
template<typename ValueType, typename Reference>
struct is_any_iterator<any_forward_iterator<ValueType, Reference>> { static constexpr bool value = true; };
template<typename ValueType, typename Reference, typename Pointer>
struct is_any_iterator<any_forward_iterator<ValueType, Reference, Pointer>> { static constexpr bool value = true; };
template<typename ValueType>
struct is_any_iterator<any_bidirectional_iterator<ValueType>> { static constexpr bool value = true; };
template<typename ValueType, typename Reference, typename Pointer>
struct is_any_iterator<any_bidirectional_iterator<ValueType, Reference, Pointer>> { static constexpr bool value = true; };
template<typename ValueType>
struct is_any_iterator<any_random_access_iterator<ValueType>> { static constexpr bool value = true; };
template<typename ValueType, typename Reference, typename Pointer>
struct is_any_iterator<any_random_access_iterator<ValueType, Reference, Pointer>> { static constexpr bool value = true; };
@ -285,9 +285,10 @@ struct out_it_holder : out_it_holder_base<ValueType> {
};
template<typename ValueType, typename Reference>
template<typename ValueType, typename Reference, typename Pointer>
struct fwd_it_holder_base {
using reference = Reference;
using pointer = Pointer;
virtual ~fwd_it_holder_base() = default;
@ -307,11 +308,11 @@ struct fwd_it_holder_base {
};
template<typename ValueType, typename It>
struct fwd_it_holder : fwd_it_holder_base<ValueType, typename std::iterator_traits<It>::reference> {
struct fwd_it_holder : fwd_it_holder_base<ValueType, typename std::iterator_traits<It>::reference, typename std::iterator_traits<It>::pointer> {
// TODO: what about const ValueType? use *std::declval<It> instead? what about const_iterator?
static_assert(std::is_same<ValueType, typename std::iterator_traits<It>::value_type>::value, "iterator's value_type does not match T in any_forward_iterator<T>");
static_assert(std::is_base_of<std::forward_iterator_tag, typename std::iterator_traits<It>::iterator_category>::value, "iterator is not compatible with a forward iterator");
using parent_type = fwd_it_holder_base<ValueType, typename std::iterator_traits<It>::reference>;
using parent_type = fwd_it_holder_base<ValueType, typename std::iterator_traits<It>::reference, typename std::iterator_traits<It>::pointer>;
using reference = parent_type::reference;
fwd_it_holder(It it) : it(std::move(it)) {}
@ -352,20 +353,20 @@ struct fwd_it_holder : fwd_it_holder_base<ValueType, typename std::iterator_trai
};
template<typename ValueType, typename Reference>
template<typename ValueType, typename Reference, typename Pointer>
struct bidir_it_holder_base {
virtual ~bidir_it_holder_base() = default;
virtual void clone_as_in(detail::sbo<in_it_holder_base<ValueType>> &dest) const = 0;
virtual void clone_as_out(detail::sbo<out_it_holder_base<ValueType>> &dest) const = 0;
virtual void clone_as_fwd(detail::sbo<fwd_it_holder_base<ValueType, Reference>> &dest) const = 0;
virtual void clone_as_bidir(detail::sbo<bidir_it_holder_base<ValueType, Reference>> &dest) const = 0;
virtual void clone_as_fwd(detail::sbo<fwd_it_holder_base<ValueType, Reference, Pointer>> &dest) const = 0;
virtual void clone_as_bidir(detail::sbo<bidir_it_holder_base<ValueType, Reference, Pointer>> &dest) const = 0;
virtual void move_as_in(detail::sbo<in_it_holder_base<ValueType>> &dest) = 0;
virtual void move_as_out(detail::sbo<out_it_holder_base<ValueType>> &dest) = 0;
virtual void move_as_fwd(detail::sbo<fwd_it_holder_base<ValueType, Reference>> &dest) = 0;
virtual void move_as_bidir(detail::sbo<bidir_it_holder_base<ValueType, Reference>> &dest) = 0;
virtual void move_as_fwd(detail::sbo<fwd_it_holder_base<ValueType, Reference, Pointer>> &dest) = 0;
virtual void move_as_bidir(detail::sbo<bidir_it_holder_base<ValueType, Reference, Pointer>> &dest) = 0;
virtual bool equal_to(const bidir_it_holder_base<ValueType, Reference> &other) const = 0;
virtual bool equal_to(const bidir_it_holder_base<ValueType, Reference, Pointer> &other) const = 0;
virtual void next() = 0;
virtual void prev() = 0;
@ -374,12 +375,13 @@ struct bidir_it_holder_base {
};
template<typename ValueType, typename It>
struct bidir_it_holder : bidir_it_holder_base<ValueType, typename std::iterator_traits<It>::reference> {
struct bidir_it_holder : bidir_it_holder_base<ValueType, typename std::iterator_traits<It>::reference, typename std::iterator_traits<It>::pointer> {
// TODO: what about const ValueType? use *std::declval<It> instead? what about const_iterator?
static_assert(std::is_same<ValueType, typename std::iterator_traits<It>::value_type>::value, "iterator's value_type does not match T in any_bidirectional_iterator<T>");
static_assert(std::is_base_of<std::bidirectional_iterator_tag, typename std::iterator_traits<It>::iterator_category>::value, "iterator is not compatible with a bidirectional iterator");
using parent_type = bidir_it_holder_base<ValueType, typename std::iterator_traits<It>::reference>;
using parent_type = bidir_it_holder_base<ValueType, typename std::iterator_traits<It>::reference, typename std::iterator_traits<It>::pointer>;
using reference = parent_type::reference;
using pointer = parent_type::pointer;
bidir_it_holder(It it) : it(std::move(it)) {}
@ -391,7 +393,7 @@ struct bidir_it_holder : bidir_it_holder_base<ValueType, typename std::iterator_
dest.replace(detail::in_place_t<out_it_holder<ValueType, It>>{}, it);
}
void clone_as_fwd(detail::sbo<fwd_it_holder_base<ValueType, reference>> &dest) const override {
void clone_as_fwd(detail::sbo<fwd_it_holder_base<ValueType, reference, pointer>> &dest) const override {
dest.replace(detail::in_place_t<fwd_it_holder<ValueType, It>>{}, it);
}
@ -408,7 +410,7 @@ struct bidir_it_holder : bidir_it_holder_base<ValueType, typename std::iterator_
dest.replace(detail::in_place_t<out_it_holder<ValueType, It>>{}, std::move(it));
}
void move_as_fwd(detail::sbo<fwd_it_holder_base<ValueType, reference>> &dest) override {
void move_as_fwd(detail::sbo<fwd_it_holder_base<ValueType, reference, pointer>> &dest) override {
dest.replace(detail::in_place_t<fwd_it_holder<ValueType, It>>{}, std::move(it));
}
@ -428,43 +430,45 @@ struct bidir_it_holder : bidir_it_holder_base<ValueType, typename std::iterator_
};
template<typename ValueType, typename Reference>
template<typename ValueType, typename Reference, typename Pointer>
struct rand_it_holder_base {
using reference = Reference;
using pointer = Pointer;
virtual ~rand_it_holder_base() = default;
virtual void clone_as_in(detail::sbo<in_it_holder_base<ValueType>> &dest) const = 0;
virtual void clone_as_out(detail::sbo<out_it_holder_base<ValueType>> &dest) const = 0;
virtual void clone_as_fwd(detail::sbo<fwd_it_holder_base<ValueType, Reference>> &dest) const = 0;
virtual void clone_as_bidir(detail::sbo<bidir_it_holder_base<ValueType, Reference>> &dest) const = 0;
virtual void clone_as_rand(detail::sbo<rand_it_holder_base<ValueType, Reference>> &dest) const = 0;
virtual void clone_as_fwd(detail::sbo<fwd_it_holder_base<ValueType, Reference, Pointer>> &dest) const = 0;
virtual void clone_as_bidir(detail::sbo<bidir_it_holder_base<ValueType, Reference, Pointer>> &dest) const = 0;
virtual void clone_as_rand(detail::sbo<rand_it_holder_base<ValueType, Reference, Pointer>> &dest) const = 0;
virtual void move_as_in(detail::sbo<in_it_holder_base<ValueType>> &dest) = 0;
virtual void move_as_out(detail::sbo<out_it_holder_base<ValueType>> &dest) = 0;
virtual void move_as_fwd(detail::sbo<fwd_it_holder_base<ValueType, Reference>> &dest) = 0;
virtual void move_as_bidir(detail::sbo<bidir_it_holder_base<ValueType, Reference>> &dest) = 0;
virtual void move_as_rand(detail::sbo<rand_it_holder_base<ValueType, Reference>> &dest) = 0;
virtual void move_as_fwd(detail::sbo<fwd_it_holder_base<ValueType, Reference, Pointer>> &dest) = 0;
virtual void move_as_bidir(detail::sbo<bidir_it_holder_base<ValueType, Reference, Pointer>> &dest) = 0;
virtual void move_as_rand(detail::sbo<rand_it_holder_base<ValueType, Reference, Pointer>> &dest) = 0;
virtual bool equal_to(const rand_it_holder_base<ValueType, Reference> &other) const = 0;
virtual bool less(const rand_it_holder_base<ValueType, Reference> &other) const = 0;
virtual bool equal_to(const rand_it_holder_base<ValueType, Reference, Pointer> &other) const = 0;
virtual bool less(const rand_it_holder_base<ValueType, Reference, Pointer> &other) const = 0;
virtual void next() = 0;
virtual void prev() = 0;
virtual void add(std::ptrdiff_t n) = 0;
virtual std::ptrdiff_t diff(const rand_it_holder_base<ValueType, Reference> &other) const = 0;
virtual std::ptrdiff_t diff(const rand_it_holder_base<ValueType, Reference, Pointer> &other) const = 0;
virtual reference get() const = 0;
};
template<typename ValueType, typename It>
struct rand_it_holder : rand_it_holder_base<ValueType, typename std::iterator_traits<It>::reference> {
struct rand_it_holder : rand_it_holder_base<ValueType, typename std::iterator_traits<It>::reference, typename std::iterator_traits<It>::pointer> {
// TODO: what about const ValueType? use *std::declval<It> instead? what about const_iterator?
static_assert(std::is_same<ValueType, typename std::iterator_traits<It>::value_type>::value, "iterator's value_type does not match T in any_random_access_iterator<T>");
static_assert(std::is_base_of<std::random_access_iterator_tag, typename std::iterator_traits<It>::iterator_category>::value, "iterator is not compatible with a random_access iterator");
using parent_type = rand_it_holder_base<ValueType, typename std::iterator_traits<It>::reference>;
using parent_type = rand_it_holder_base<ValueType, typename std::iterator_traits<It>::reference, typename std::iterator_traits<It>::pointer>;
using reference = parent_type::reference;
using pointer = parent_type::pointer;
rand_it_holder(It it) : it(std::move(it)) {}
@ -476,11 +480,11 @@ struct rand_it_holder : rand_it_holder_base<ValueType, typename std::iterator_tr
dest.replace(detail::in_place_t<out_it_holder<ValueType, It>>{}, it);
}
void clone_as_fwd(detail::sbo<fwd_it_holder_base<ValueType, reference>> &dest) const override {
void clone_as_fwd(detail::sbo<fwd_it_holder_base<ValueType, reference, pointer>> &dest) const override {
dest.replace(detail::in_place_t<fwd_it_holder<ValueType, It>>{}, it);
}
void clone_as_bidir(detail::sbo<bidir_it_holder_base<ValueType, reference>> &dest) const override {
void clone_as_bidir(detail::sbo<bidir_it_holder_base<ValueType, reference, pointer>> &dest) const override {
dest.replace(detail::in_place_t<bidir_it_holder<ValueType, It>>{}, it);
}
@ -497,11 +501,11 @@ struct rand_it_holder : rand_it_holder_base<ValueType, typename std::iterator_tr
dest.replace(detail::in_place_t<out_it_holder<ValueType, It>>{}, std::move(it));
}
void move_as_fwd(detail::sbo<fwd_it_holder_base<ValueType, reference>> &dest) override {
void move_as_fwd(detail::sbo<fwd_it_holder_base<ValueType, reference, pointer>> &dest) override {
dest.replace(detail::in_place_t<fwd_it_holder<ValueType, It>>{}, std::move(it));
}
void move_as_bidir(detail::sbo<bidir_it_holder_base<ValueType, reference>> &dest) override {
void move_as_bidir(detail::sbo<bidir_it_holder_base<ValueType, reference, pointer>> &dest) override {
dest.replace(detail::in_place_t<bidir_it_holder<ValueType, It>>{}, std::move(it));
}
@ -562,10 +566,11 @@ struct empty_out_it_holder : out_it_holder_base<ValueType> {
};
template<typename ValueType, typename Reference>
struct empty_fwd_it_holder : fwd_it_holder_base<ValueType, Reference> {
using parent_type = fwd_it_holder_base<ValueType, Reference>;
template<typename ValueType, typename Reference, typename Pointer>
struct empty_fwd_it_holder : fwd_it_holder_base<ValueType, Reference, Pointer> {
using parent_type = fwd_it_holder_base<ValueType, Reference, Pointer>;
using reference = Reference;
using pointer = Pointer;
void clone_as_in(detail::sbo<in_it_holder_base<ValueType>> &dest) const override {
dest.replace(detail::in_place_t<empty_in_it_holder<ValueType>>{});
@ -599,10 +604,11 @@ struct empty_fwd_it_holder : fwd_it_holder_base<ValueType, Reference> {
};
template<typename ValueType, typename Reference>
struct empty_bidir_it_holder : bidir_it_holder_base<ValueType, Reference> {
using parent_type = bidir_it_holder_base<ValueType, Reference>;
template<typename ValueType, typename Reference, typename Pointer>
struct empty_bidir_it_holder : bidir_it_holder_base<ValueType, Reference, Pointer> {
using parent_type = bidir_it_holder_base<ValueType, Reference, Pointer>;
using reference = Reference;
using pointer = Pointer;
void clone_as_in(detail::sbo<in_it_holder_base<ValueType>> &dest) const override {
dest.replace(detail::in_place_t<empty_in_it_holder<ValueType>>{});
@ -612,8 +618,8 @@ struct empty_bidir_it_holder : bidir_it_holder_base<ValueType, Reference> {
dest.replace(detail::in_place_t<empty_out_it_holder<ValueType>>{});
}
void clone_as_fwd(detail::sbo<fwd_it_holder_base<ValueType, Reference>> &dest) const override {
dest.replace(detail::in_place_t<empty_fwd_it_holder<ValueType, Reference>>{});
void clone_as_fwd(detail::sbo<fwd_it_holder_base<ValueType, Reference, Pointer>> &dest) const override {
dest.replace(detail::in_place_t<empty_fwd_it_holder<ValueType, Reference, Pointer>>{});
}
void clone_as_bidir(detail::sbo<parent_type> &dest) const override {
@ -628,8 +634,8 @@ struct empty_bidir_it_holder : bidir_it_holder_base<ValueType, Reference> {
dest.replace(detail::in_place_t<empty_out_it_holder<ValueType>>{});
}
void move_as_fwd(detail::sbo<fwd_it_holder_base<ValueType, Reference>> &dest) override {
dest.replace(detail::in_place_t<empty_fwd_it_holder<ValueType, Reference>>{});
void move_as_fwd(detail::sbo<fwd_it_holder_base<ValueType, Reference, Pointer>> &dest) override {
dest.replace(detail::in_place_t<empty_fwd_it_holder<ValueType, Reference, Pointer>>{});
}
void move_as_bidir(detail::sbo<parent_type> &dest) override {
@ -645,10 +651,11 @@ struct empty_bidir_it_holder : bidir_it_holder_base<ValueType, Reference> {
};
template<typename ValueType, typename Reference>
struct empty_rand_it_holder : rand_it_holder_base<ValueType, Reference> {
using parent_type = rand_it_holder_base<ValueType, Reference>;
template<typename ValueType, typename Reference, typename Pointer>
struct empty_rand_it_holder : rand_it_holder_base<ValueType, Reference, Pointer> {
using parent_type = rand_it_holder_base<ValueType, Reference, Pointer>;
using reference = Reference;
using pointer = Pointer;
void clone_as_in(detail::sbo<in_it_holder_base<ValueType>> &dest) const override {
dest.replace(detail::in_place_t<empty_in_it_holder<ValueType>>{});
@ -658,12 +665,12 @@ struct empty_rand_it_holder : rand_it_holder_base<ValueType, Reference> {
dest.replace(detail::in_place_t<empty_out_it_holder<ValueType>>{});
}
void clone_as_fwd(detail::sbo<fwd_it_holder_base<ValueType, Reference>> &dest) const override {
dest.replace(detail::in_place_t<empty_fwd_it_holder<ValueType, Reference>>{});
void clone_as_fwd(detail::sbo<fwd_it_holder_base<ValueType, Reference, Pointer>> &dest) const override {
dest.replace(detail::in_place_t<empty_fwd_it_holder<ValueType, Reference, Pointer>>{});
}
void clone_as_bidir(detail::sbo<bidir_it_holder_base<ValueType, Reference>> &dest) const override {
dest.replace(detail::in_place_t<empty_bidir_it_holder<ValueType, Reference>>{});
void clone_as_bidir(detail::sbo<bidir_it_holder_base<ValueType, Reference, Pointer>> &dest) const override {
dest.replace(detail::in_place_t<empty_bidir_it_holder<ValueType, Reference, Pointer>>{});
}
void clone_as_rand(detail::sbo<parent_type> &dest) const override {
@ -678,12 +685,12 @@ struct empty_rand_it_holder : rand_it_holder_base<ValueType, Reference> {
dest.replace(detail::in_place_t<empty_out_it_holder<ValueType>>{});
}
void move_as_fwd(detail::sbo<fwd_it_holder_base<ValueType, Reference>> &dest) override {
dest.replace(detail::in_place_t<empty_fwd_it_holder<ValueType, Reference>>{});
void move_as_fwd(detail::sbo<fwd_it_holder_base<ValueType, Reference, Pointer>> &dest) override {
dest.replace(detail::in_place_t<empty_fwd_it_holder<ValueType, Reference, Pointer>>{});
}
void move_as_bidir(detail::sbo<bidir_it_holder_base<ValueType, Reference>> &dest) override {
dest.replace(detail::in_place_t<empty_bidir_it_holder<ValueType, Reference>>{});
void move_as_bidir(detail::sbo<bidir_it_holder_base<ValueType, Reference, Pointer>> &dest) override {
dest.replace(detail::in_place_t<empty_bidir_it_holder<ValueType, Reference, Pointer>>{});
}
void move_as_rand(detail::sbo<parent_type> &dest) override {
@ -870,7 +877,7 @@ private:
template<typename ValueType, typename Reference=ValueType&>
template<typename ValueType, typename Reference=ValueType&, typename Pointer=ValueType*>
struct any_forward_iterator {
using iterator_category = std::forward_iterator_tag;
using value_type = ValueType;
@ -878,10 +885,10 @@ struct any_forward_iterator {
using pointer = ValueType*;
using reference = Reference;
any_forward_iterator() : it(detail::in_place_t<detail::empty_fwd_it_holder<ValueType, Reference>>{}) {}
any_forward_iterator() : it(detail::in_place_t<detail::empty_fwd_it_holder<ValueType, Reference, Pointer>>{}) {}
template<typename It>
any_forward_iterator(It &&it, typename std::enable_if<!detail::is_compatible_it<typename std::decay<It>::type, any_forward_iterator<ValueType>>::value>::type* = nullptr)
any_forward_iterator(It &&it, typename std::enable_if<!detail::is_compatible_it<typename std::decay<It>::type, any_forward_iterator>::value>::type* = nullptr)
: it(detail::in_place_t<detail::fwd_it_holder<ValueType, typename std::decay<It>::type>>{}, std::forward<It>(it)) {}
any_forward_iterator(const any_forward_iterator &other) : it() { other.it->clone_as_fwd(it); }
@ -890,12 +897,12 @@ struct any_forward_iterator {
template<typename It>
any_forward_iterator &assign(It &&new_it, typename std::enable_if<!detail::is_compatible_it<typename std::decay<It>::type, any_forward_iterator<ValueType>>::value>::type* = nullptr) {
any_forward_iterator &assign(It &&new_it, typename std::enable_if<!detail::is_compatible_it<typename std::decay<It>::type, any_forward_iterator>::value>::type* = nullptr) {
it.replace(detail::in_place_t<detail::fwd_it_holder<ValueType, typename std::decay<It>::type>>{}, std::forward<It>(new_it));
return *this;
}
template<typename It, typename = typename std::enable_if<!std::is_same<any_forward_iterator<ValueType>, typename std::decay<It>::type>::value>::type>
template<typename It, typename = typename std::enable_if<!std::is_same<any_forward_iterator, typename std::decay<It>::type>::value>::type>
any_forward_iterator &operator=(It &&it) { return assign(std::forward<It>(it)); }
any_forward_iterator &operator=(const any_forward_iterator &other) {
@ -910,7 +917,7 @@ struct any_forward_iterator {
template<typename AnyIt>
any_forward_iterator(AnyIt &&other, typename std::enable_if<detail::is_compatible_it<typename std::decay<AnyIt>::type, any_forward_iterator<ValueType>>::value>::type* = nullptr) : it() {
any_forward_iterator(AnyIt &&other, typename std::enable_if<detail::is_compatible_it<typename std::decay<AnyIt>::type, any_forward_iterator>::value>::type* = nullptr) : it() {
if(std::is_reference<AnyIt>::value)
other.it->clone_as_fwd(it);
else
@ -918,7 +925,7 @@ struct any_forward_iterator {
}
template<typename AnyIt>
any_forward_iterator &assign(AnyIt &&other, typename std::enable_if<detail::is_compatible_it<typename std::decay<AnyIt>::type, any_forward_iterator<ValueType>>::value>::type* = nullptr) {
any_forward_iterator &assign(AnyIt &&other, typename std::enable_if<detail::is_compatible_it<typename std::decay<AnyIt>::type, any_forward_iterator>::value>::type* = nullptr) {
if(std::is_reference<AnyIt>::value)
other.it->clone_as_fwd(it);
else
@ -927,39 +934,39 @@ struct any_forward_iterator {
}
ValueType &operator*() const { return it->get(); }
ValueType *operator->() const { return &it->get(); }
reference operator*() const { return it->get(); }
pointer operator->() const { return &it->get(); }
any_forward_iterator &operator++() { it->next(); return *this; }
any_forward_iterator operator++(int) {
any_forward_iterator<ValueType> ret(*this);
any_forward_iterator ret(*this);
it->next();
return ret;
}
private:
template<typename T, typename U>
friend bool operator==(const any_forward_iterator<T, U> &left, const any_forward_iterator<T, U> &right);
template<typename T, typename U, typename V>
friend bool operator==(const any_forward_iterator<T, U, V> &left, const any_forward_iterator<T, U, V> &right);
detail::sbo<detail::fwd_it_holder_base<ValueType, Reference>> it;
detail::sbo<detail::fwd_it_holder_base<ValueType, Reference, Pointer>> it;
};
template<typename ValueType, typename Reference=ValueType&>
bool operator==(const any_forward_iterator<ValueType, Reference> &left, const any_forward_iterator<ValueType, Reference> &right) {
template<typename ValueType, typename Reference, typename Pointer>
bool operator==(const any_forward_iterator<ValueType, Reference, Pointer> &left, const any_forward_iterator<ValueType, Reference, Pointer> &right) {
return left.it->equal_to(*right.it);
}
template<typename ValueType, typename Reference=ValueType&>
bool operator!=(const any_forward_iterator<ValueType, Reference> &left, const any_forward_iterator<ValueType, Reference> &right) {
template<typename ValueType, typename Reference, typename Pointer>
bool operator!=(const any_forward_iterator<ValueType, Reference, Pointer> &left, const any_forward_iterator<ValueType, Reference, Pointer> &right) {
return !(left == right);
}
template<typename ValueType, typename Reference>
template<typename ValueType, typename Reference, typename Pointer>
struct any_bidirectional_iterator {
using iterator_category = std::bidirectional_iterator_tag;
using value_type = ValueType;
@ -967,10 +974,10 @@ struct any_bidirectional_iterator {
using pointer = ValueType*;
using reference = Reference;
any_bidirectional_iterator() : it(detail::in_place_t<detail::empty_bidir_it_holder<ValueType, Reference>>{}) {}
any_bidirectional_iterator() : it(detail::in_place_t<detail::empty_bidir_it_holder<ValueType, Reference, Pointer>>{}) {}
template<typename It>
any_bidirectional_iterator(It &&it, typename std::enable_if<!detail::is_compatible_it<typename std::decay<It>::type, any_bidirectional_iterator<ValueType>>::value>::type* = nullptr)
any_bidirectional_iterator(It &&it, typename std::enable_if<!detail::is_compatible_it<typename std::decay<It>::type, any_bidirectional_iterator>::value>::type* = nullptr)
: it(detail::in_place_t<detail::bidir_it_holder<ValueType, typename std::decay<It>::type>>{}, std::forward<It>(it)) {}
any_bidirectional_iterator(const any_bidirectional_iterator &other) : it() { other.it->clone_as_bidir(it); }
@ -979,12 +986,12 @@ struct any_bidirectional_iterator {
template<typename It>
any_bidirectional_iterator &assign(It &&new_it, typename std::enable_if<!detail::is_compatible_it<typename std::decay<It>::type, any_bidirectional_iterator<ValueType>>::value>::type* = nullptr) {
any_bidirectional_iterator &assign(It &&new_it, typename std::enable_if<!detail::is_compatible_it<typename std::decay<It>::type, any_bidirectional_iterator>::value>::type* = nullptr) {
it.replace(detail::in_place_t<detail::bidir_it_holder<ValueType, typename std::decay<It>::type>>{}, std::forward<It>(new_it));
return *this;
}
template<typename It, typename = typename std::enable_if<!std::is_same<any_bidirectional_iterator<ValueType>, typename std::decay<It>::type>::value>::type>
template<typename It, typename = typename std::enable_if<!std::is_same<any_bidirectional_iterator, typename std::decay<It>::type>::value>::type>
any_bidirectional_iterator &operator=(It &&it) { return assign(std::forward<It>(it)); }
any_bidirectional_iterator &operator=(const any_bidirectional_iterator &other) {
@ -999,7 +1006,7 @@ struct any_bidirectional_iterator {
template<typename AnyIt>
any_bidirectional_iterator(AnyIt &&other, typename std::enable_if<detail::is_compatible_it<typename std::decay<AnyIt>::type, any_bidirectional_iterator<ValueType>>::value>::type* = nullptr) : it() {
any_bidirectional_iterator(AnyIt &&other, typename std::enable_if<detail::is_compatible_it<typename std::decay<AnyIt>::type, any_bidirectional_iterator>::value>::type* = nullptr) : it() {
if(std::is_reference<AnyIt>::value)
other.it->clone_as_bidir(it);
else
@ -1007,7 +1014,7 @@ struct any_bidirectional_iterator {
}
template<typename AnyIt>
any_bidirectional_iterator &assign(AnyIt &&other, typename std::enable_if<detail::is_compatible_it<typename std::decay<AnyIt>::type, any_bidirectional_iterator<ValueType>>::value>::type* = nullptr) {
any_bidirectional_iterator &assign(AnyIt &&other, typename std::enable_if<detail::is_compatible_it<typename std::decay<AnyIt>::type, any_bidirectional_iterator>::value>::type* = nullptr) {
if(std::is_reference<AnyIt>::value)
other.it->clone_as_bidir(it);
else
@ -1016,14 +1023,14 @@ struct any_bidirectional_iterator {
}
Reference operator*() const { return it->get(); }
ValueType *operator->() const { return &it->get(); }
reference operator*() const { return it->get(); }
pointer operator->() const { return &it->get(); }
any_bidirectional_iterator &operator++() { it->next(); return *this; }
any_bidirectional_iterator operator++(int) {
any_bidirectional_iterator<ValueType> ret(*this);
any_bidirectional_iterator ret(*this);
it->next();
return ret;
}
@ -1031,32 +1038,32 @@ struct any_bidirectional_iterator {
any_bidirectional_iterator &operator--() { it->prev(); return *this; }
any_bidirectional_iterator operator--(int) {
any_bidirectional_iterator<ValueType> ret(*this);
any_bidirectional_iterator ret(*this);
it->prev();
return ret;
}
private:
template<typename T, typename U>
friend bool operator==(const any_bidirectional_iterator<T, U> &left, const any_bidirectional_iterator<T, U> &right);
template<typename T, typename U, typename V>
friend bool operator==(const any_bidirectional_iterator<T, U, V> &left, const any_bidirectional_iterator<T, U, V> &right);
detail::sbo<detail::bidir_it_holder_base<ValueType, Reference>> it;
detail::sbo<detail::bidir_it_holder_base<ValueType, Reference, Pointer>> it;
};
template<typename ValueType>
bool operator==(const any_bidirectional_iterator<ValueType> &left, const any_bidirectional_iterator<ValueType> &right) {
template<typename ValueType, typename Reference, typename Pointer>
bool operator==(const any_bidirectional_iterator<ValueType, Reference, Pointer> &left, const any_bidirectional_iterator<ValueType, Reference, Pointer> &right) {
return left.it->equal_to(*right.it);
}
template<typename ValueType>
bool operator!=(const any_bidirectional_iterator<ValueType> &left, const any_bidirectional_iterator<ValueType> &right) {
template<typename ValueType, typename Reference, typename Pointer>
bool operator!=(const any_bidirectional_iterator<ValueType, Reference, Pointer> &left, const any_bidirectional_iterator<ValueType, Reference, Pointer> &right) {
return !(left == right);
}
template<typename ValueType, typename Reference>
template<typename ValueType, typename Reference, typename Pointer>
struct any_random_access_iterator {
using iterator_category = std::random_access_iterator_tag;
using value_type = ValueType;
@ -1064,10 +1071,10 @@ struct any_random_access_iterator {
using pointer = ValueType*;
using reference = Reference;
any_random_access_iterator() : it(detail::in_place_t<detail::empty_rand_it_holder<ValueType, Reference>>{}) {}
any_random_access_iterator() : it(detail::in_place_t<detail::empty_rand_it_holder<ValueType, Reference, Pointer>>{}) {}
template<typename It, typename = typename std::enable_if<
!detail::is_compatible_it<typename std::decay<It>::type, any_random_access_iterator<ValueType>>::value
!detail::is_compatible_it<typename std::decay<It>::type, any_random_access_iterator>::value
>::type>
any_random_access_iterator(It &&it) : it(detail::in_place_t<detail::rand_it_holder<ValueType, typename std::decay<It>::type>>{}, std::forward<It>(it)) {}
@ -1077,14 +1084,14 @@ struct any_random_access_iterator {
template<typename It, typename = typename std::enable_if<
!detail::is_compatible_it<typename std::decay<It>::type, any_random_access_iterator<ValueType>>::value
!detail::is_compatible_it<typename std::decay<It>::type, any_random_access_iterator>::value
>::type>
any_random_access_iterator &assign(It &&new_it) {
it.replace(detail::in_place_t<detail::rand_it_holder<ValueType, typename std::decay<It>::type>>{}, std::forward<It>(new_it));
return *this;
}
template<typename It, typename = typename std::enable_if<!std::is_same<any_random_access_iterator<ValueType>, typename std::decay<It>::type>::value>::type>
template<typename It, typename = typename std::enable_if<!std::is_same<any_random_access_iterator, typename std::decay<It>::type>::value>::type>
any_random_access_iterator &operator=(It &&it) { return assign(std::forward<It>(it)); }
any_random_access_iterator &operator=(const any_random_access_iterator &other) {
@ -1099,13 +1106,13 @@ struct any_random_access_iterator {
reference operator*() const { return it->get(); }
ValueType *operator->() const { return &it->get(); }
pointer operator->() const { return &it->get(); }
any_random_access_iterator &operator++() { it->next(); return *this; }
any_random_access_iterator operator++(int) {
any_random_access_iterator<ValueType> ret(*this);
any_random_access_iterator ret(*this);
it->next();
return ret;
}
@ -1113,7 +1120,7 @@ struct any_random_access_iterator {
any_random_access_iterator &operator--() { it->prev(); return *this; }
any_random_access_iterator operator--(int) {
any_random_access_iterator<ValueType> ret(*this);
any_random_access_iterator ret(*this);
it->prev();
return ret;
}
@ -1129,71 +1136,71 @@ struct any_random_access_iterator {
}
private:
template<typename T, typename U>
friend bool operator==(const any_random_access_iterator<T,U> &left, const any_random_access_iterator<T,U> &right);
template<typename T, typename U, typename V>
friend bool operator==(const any_random_access_iterator<T,U,V> &left, const any_random_access_iterator<T,U,V> &right);
template<typename T, typename U>
friend bool operator<(const any_random_access_iterator<T,U> &left, const any_random_access_iterator<T,U> &right);
template<typename T, typename U, typename V>
friend bool operator<(const any_random_access_iterator<T,U,V> &left, const any_random_access_iterator<T,U,V> &right);
template<typename T, typename U>
friend bool operator>(const any_random_access_iterator<T,U> &left, const any_random_access_iterator<T,U> &right);
template<typename T, typename U, typename V>
friend bool operator>(const any_random_access_iterator<T,U,V> &left, const any_random_access_iterator<T,U,V> &right);
template<typename T, typename U>
friend std::ptrdiff_t operator-(const any_random_access_iterator<T,U> &left, const any_random_access_iterator<T,U> &right);
template<typename T, typename U, typename V>
friend std::ptrdiff_t operator-(const any_random_access_iterator<T,U,V> &left, const any_random_access_iterator<T,U,V> &right);
detail::sbo<detail::rand_it_holder_base<ValueType, Reference>> it;
detail::sbo<detail::rand_it_holder_base<ValueType, Reference, Pointer>> it;
};
template<typename ValueType, typename Reference>
bool operator==(const any_random_access_iterator<ValueType, Reference> &left, const any_random_access_iterator<ValueType, Reference> &right) {
template<typename ValueType, typename Reference, typename Pointer>
bool operator==(const any_random_access_iterator<ValueType, Reference, Pointer> &left, const any_random_access_iterator<ValueType, Reference, Pointer> &right) {
return left.it->equal_to(*right.it);
}
template<typename ValueType, typename Reference>
bool operator!=(const any_random_access_iterator<ValueType, Reference> &left, const any_random_access_iterator<ValueType, Reference> &right) {
template<typename ValueType, typename Reference, typename Pointer>
bool operator!=(const any_random_access_iterator<ValueType, Reference, Pointer> &left, const any_random_access_iterator<ValueType, Reference, Pointer> &right) {
return !(left == right);
}
template<typename ValueType, typename Reference>
bool operator<(const any_random_access_iterator<ValueType, Reference> &left, const any_random_access_iterator<ValueType, Reference> &right) {
template<typename ValueType, typename Reference, typename Pointer>
bool operator<(const any_random_access_iterator<ValueType, Reference, Pointer> &left, const any_random_access_iterator<ValueType, Reference, Pointer> &right) {
return left.it->less(*right.it);
}
template<typename ValueType, typename Reference>
bool operator>=(const any_random_access_iterator<ValueType, Reference> &left, const any_random_access_iterator<ValueType, Reference> &right) {
template<typename ValueType, typename Reference, typename Pointer>
bool operator>=(const any_random_access_iterator<ValueType, Reference, Pointer> &left, const any_random_access_iterator<ValueType, Reference, Pointer> &right) {
return !(left < right);
}
template<typename ValueType, typename Reference>
bool operator>(const any_random_access_iterator<ValueType, Reference> &left, const any_random_access_iterator<ValueType, Reference> &right) {
template<typename ValueType, typename Reference, typename Pointer>
bool operator>(const any_random_access_iterator<ValueType, Reference, Pointer> &left, const any_random_access_iterator<ValueType, Reference, Pointer> &right) {
return right.it->less(*left.it);
}
template<typename ValueType, typename Reference>
bool operator<=(const any_random_access_iterator<ValueType, Reference> &left, const any_random_access_iterator<ValueType, Reference> &right) {
template<typename ValueType, typename Reference, typename Pointer>
bool operator<=(const any_random_access_iterator<ValueType, Reference, Pointer> &left, const any_random_access_iterator<ValueType, Reference, Pointer> &right) {
return !(right < left);
}
template<typename ValueType, typename Reference>
std::ptrdiff_t operator-(const any_random_access_iterator<ValueType> &left, const any_random_access_iterator<ValueType> &right) {
template<typename ValueType, typename Reference, typename Pointer>
std::ptrdiff_t operator-(const any_random_access_iterator<ValueType, Reference, Pointer> &left, const any_random_access_iterator<ValueType, Reference, Pointer> &right) {
return left.it->diff(*right.it);
}
template<typename ValueType, typename Reference>
any_random_access_iterator<ValueType, Reference> operator+(const any_random_access_iterator<ValueType, Reference> &it, std::ptrdiff_t n) {
any_random_access_iterator<ValueType, Reference> ret(it);
template<typename ValueType, typename Reference, typename Pointer>
any_random_access_iterator<ValueType, Reference, Pointer> operator+(const any_random_access_iterator<ValueType, Reference, Pointer> &it, std::ptrdiff_t n) {
any_random_access_iterator<ValueType, Reference, Pointer> ret(it);
return ret += n;
}
template<typename ValueType, typename Reference>
any_random_access_iterator<ValueType, Reference> operator+(std::ptrdiff_t n, const any_random_access_iterator<ValueType, Reference> &it) {
template<typename ValueType, typename Reference, typename Pointer>
any_random_access_iterator<ValueType, Reference, Pointer> operator+(std::ptrdiff_t n, const any_random_access_iterator<ValueType, Reference, Pointer> &it) {
return it + n;
}
template<typename ValueType, typename Reference>
any_random_access_iterator<ValueType, Reference> operator-(const any_random_access_iterator<ValueType, Reference> &it, std::ptrdiff_t n) {
template<typename ValueType, typename Reference, typename Pointer>
any_random_access_iterator<ValueType, Reference, Pointer> operator-(const any_random_access_iterator<ValueType, Reference, Pointer> &it, std::ptrdiff_t n) {
return it + -n;
}

View file

@ -31,6 +31,7 @@ class SavegameDb;
class SavegameModel {
public:
typedef liph::any_forward_iterator<
mc::psx::BasicBlock<false>,
mc::psx::BasicBlock<false>,
mc::psx::BasicBlock<false>
> iterator;

View file

@ -63,6 +63,9 @@ public:
template <bool Const2> BasicBlock(const BasicBlock<Const2>& other);
~BasicBlock();
BasicBlock* operator->() {return this;}
const BasicBlock* operator->() const {return this;}
iterator begin();
iterator end();
const_iterator cbegin() const;