mirror of
https://github.com/QuasarApp/LIEF.git
synced 2025-04-30 06:14:37 +00:00
Fix bug in windows
This commit is contained in:
parent
dee5c07784
commit
2042b750e0
@ -132,9 +132,19 @@ class ref_iterator : public std::iterator<
|
|||||||
if (n >= this->size()) {
|
if (n >= this->size()) {
|
||||||
throw integrity_error(std::to_string(n) + " is out of bound");
|
throw integrity_error(std::to_string(n) + " is out of bound");
|
||||||
}
|
}
|
||||||
auto it = this->begin();
|
|
||||||
std::advance(it, n);
|
ref_iterator* no_const_this = const_cast<ref_iterator*>(this);
|
||||||
return const_cast<add_const_t<ref_t>>(*it);
|
|
||||||
|
typename ref_iterator::difference_type saved_dist = std::distance(std::begin(no_const_this->container_), no_const_this->it_);
|
||||||
|
no_const_this->it_ = std::begin(no_const_this->container_);
|
||||||
|
std::advance(no_const_this->it_, n);
|
||||||
|
|
||||||
|
auto&& v = const_cast<add_const_t<ref_t>>(no_const_this->operator*());
|
||||||
|
|
||||||
|
no_const_this->it_ = std::begin(no_const_this->container_);
|
||||||
|
std::advance(no_const_this->it_, saved_dist);
|
||||||
|
|
||||||
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
ref_iterator operator+(typename ref_iterator::difference_type n) const {
|
ref_iterator operator+(typename ref_iterator::difference_type n) const {
|
||||||
|
@ -497,7 +497,11 @@ TEST_CASE("Test const filter ref iterators", "[lief][iterators][filter][const_re
|
|||||||
it_filter_const_ref bar_filtred = foo.get_bar_filter();
|
it_filter_const_ref bar_filtred = foo.get_bar_filter();
|
||||||
it_filter_const_ref_ptr bar_ptr_filtred = foo.get_bar_ptr_filter();
|
it_filter_const_ref_ptr bar_ptr_filtred = foo.get_bar_ptr_filter();
|
||||||
|
|
||||||
|
CHECK(bar_filtred[1] == "6");
|
||||||
CHECK(bar_filtred[0] == "1");
|
CHECK(bar_filtred[0] == "1");
|
||||||
|
|
||||||
|
CHECK(bar_ptr_filtred[1] == "6");
|
||||||
|
CHECK(bar_ptr_filtred[0] == "6");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user