refactor: replace Boost.Iterator with Boost.STLInterfaces - #669
refactor: replace Boost.Iterator with Boost.STLInterfaces#669sdebionne wants to merge 13 commits into
Conversation
|
@mloskot Boost.Iterator provides it's own Concept checking classes in Honestly I wonder if it is worth it, and if, for concept checking only, we could require c++20.... |
I don't think it is worth it ...
One of my "next big thing" to do for GIL is to:
@sdebionne Does the above seem sensible to you? |
|
This is included in the planning towards C++14/17 discussion here #676 |
|
I guess we may run out of time to squeeze it into Boost 1.80. What do you think @sdebionne ? |
Indeed, I underestimate the work and overestimate the time I could spend on the project. Let's move it to 1.81. |
a589fe6 to
19fdac9
Compare
19fdac9 to
9924575
Compare
9924575 to
cc957e0
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #669 +/- ##
===========================================
+ Coverage 81.97% 82.05% +0.08%
===========================================
Files 117 117
Lines 5353 5383 +30
===========================================
+ Hits 4388 4417 +29
- Misses 965 966 +1 🚀 New features to boost your workflow:
|
|
@mloskot there is still a bit of cleaning to do but otherwise this PR is ready for review. Beside the switch to Boost.StlInferface, there is a fix for the CI (code coverage), and a fix for I don't known why some of the CI GitHub actions timeout -I have just try to rerun them. |
It looks like GHA runners availability issue which I'd ignore: The Ubuntu 18.04 has also been deprecated, so I have just tried to update the GHA: Let's see if this improves anything. |
mloskot
left a comment
There was a problem hiding this comment.
Thank you so much for pulling this off @sdebionne
|
I'll rebase on the fixed CI (thank you for that) and cleanup. |
72d460c to
4470d11
Compare
|
I wonder if |
|
Yes, I think it should. It may be required as transitive dependency, but the CI jobs will let us know. |
4470d11 to
bc65b38
Compare
|
Concept checking errors with |
bc65b38 to
69a5ed2
Compare
2843fdf to
26607cb
Compare
|
The test in It does not crash with the old Boost.Iterator implementation. I compiled the develop branch's legacy/image.cpp (still using iterator_facade) at the exact same -std=c++20 with the same compiler, and it runs to completion cleanly: EXIT: 0, all ~120 checksums pass, including the planarrgb8_* cases and everything after — no segfault at all. So this is a genuine regression introduced by the Boost.Iterator → Boost.STLInterfaces conversion, specifically its C++20 concepts-enabled code path when handling nested step iterators (memory_based_step_iterator<memory_based_step_iterator<pixel*>>), and it's unrelated to my iterator_category fix (which only affects 's legacy tag-dispatch and compile-time concept checks, not this crash). It's a real bug to chase down before this branch can be considered done. |
step_iterator_adaptor (used by memory_based_step_iterator) defines its own scaled operator- as a member function. Boost.STLInterfaces' C++20 "concepts" code path (only active at cxxstd≥20) also auto-generates a fallback operator- as a free/hidden-friend template, unconditionally enabled whenever the raw underlying iterator supports subtraction: For memory_based_step_iterator<pixel*>, base() returns the raw pixel*, which is directly subtractable — so this fallback is always a candidate. Calling b - a requires converting a/b (type Derived) to invoke GIL's member operator (a derived-to-base conversion for the implicit object parameter), while the library's template fallback deduces D1=D2=Derived with zero conversions. An exact match beats a conversion, so GCC silently picks the library's fallback — returning the raw, unscaled pointer difference instead of the step-divided element count. That wrong (too-large) n then feeds directly into std::__copy_m's for (n = last-first; n>0; --n) loop, which walks the iterator far past the end of the buffer with no bounds re-check. It only shows up at cxxstd=20 because that's exactly the threshold where the library's "concepts" overload set activates.
|
Root cause constexpr auto operator-(step_iterator_adaptor other) const noexcept { return -distance_to(other); }Boost.STLInterfaces' C++20 "concepts" code path (only active at cxxstd≥20) also auto-generates a fallback operator- as a free/hidden-friend template, unconditionally enabled whenever the raw underlying iterator supports subtraction: template<typename D1, typename D2>
constexpr auto operator-(D1 lhs, D2 rhs)
requires ... requires { access::base(lhs) - access::base(rhs); }
{ return access::base(lhs) - access::base(rhs); }For Fix friend constexpr auto operator-(Derived const& lhs, Derived const& rhs) noexcept -> difference_type
{
return -lhs.distance_to(rhs);
}Now it's an equally-exact match against the library's template fallback, and the tie-break rule ("prefer a non-template over a function-template specialization") makes GCC choose GIL's correctly-scaled version. This also fixes |
|
Many clang builds fail with Root cause Fix |
Dropped the using parent_t::operator++/--; lines and added explicit local postfix operators
version `GLIBC_2.28' not found
|
CI fixes:
|
|
One last issue on macos Sonoma Root cause Fix |
d8ee9b9 to
b409769
Compare

Description
Contribute to remove dependencies to older c++03 boost libraries.
References
C++11 Modernization
Tasklist