diff --git a/Tr/TrackKernel/include/TrackKernel/TrackCompactVertex.h b/Tr/TrackKernel/include/TrackKernel/TrackCompactVertex.h index 023b23ae85708005d2fbd3526478a2c7dc68f52e..24b67b5374d919ac9987fc7ca08334c31cfb04af 100644 --- a/Tr/TrackKernel/include/TrackKernel/TrackCompactVertex.h +++ b/Tr/TrackKernel/include/TrackKernel/TrackCompactVertex.h @@ -230,27 +230,38 @@ namespace LHCb { friend auto decayProducts( const TrackCompactVertex& vtx ) { struct children_t { TrackCompactVertex const* vtx; - struct Sentinel {}; - struct Proxy { - bool operator!=( Sentinel ) const { return i != vtx->numChildren(); } - TrackCompactVertex const* vtx; - unsigned i; - Proxy& operator++() { + struct iterator_t { + using difference_type [[maybe_unused]] = std::ptrdiff_t; + using value_type [[maybe_unused]] = iterator_t; + using iterator_concept [[maybe_unused]] = std::input_iterator_tag; + using iterator_category [[maybe_unused]] = std::input_iterator_tag; + + TrackCompactVertex const* vtx = nullptr; + unsigned i = -1; + iterator_t& operator++() { ++i; return *this; } + iterator_t operator++( int ) { + auto i = *this; + ++*this; + return i; + } const auto& operator*() const { return *this; } + bool operator==( std::default_sentinel_t ) const { return !vtx || i == vtx->numChildren(); } // hack - hack -- client code sofar only needs mag2 of a vector.... // so instead we need another customization point which default to returning threeMomentum(x).mag2()... auto threeMomentum() const { return LHCb::LinAlg::Vec{ 0, 0, vtx->daughters.P( i ) }; } }; - Proxy begin() const { return { vtx, 0 }; } - Sentinel end() const { return {}; } - Proxy operator[]( unsigned i ) { return { vtx, i }; } - auto size() const { return vtx->numChildren(); } + static_assert( std::input_iterator ); + iterator_t begin() { return { vtx, 0 }; } + std::default_sentinel_t end() { return {}; } + iterator_t operator[]( unsigned i ) { return { vtx, i }; } + auto size() const { return vtx->numChildren(); } }; + static_assert( std::ranges::viewable_range ); return children_t{ &vtx }; }