Skip to content

overlap_find_next_in_subtree calls overlap_find_i_ex with invalid arguments #63

Description

@mutetea

Summary

overlap_find_next_in_subtree fails to compile because it passes exclusive as a third function argument:

overlap_find_i_ex(from.node_, ival, exclusive)

However, overlap_find_i_ex accepts only two arguments and represents exclusivity as a template parameter:

template <bool Exclusive>
node_type* overlap_find_i_ex(
node_type* ptr,
interval_type const& ival
) const;

The caller must invoke either overlap_find_i_ex<true> or overlap_find_i_ex<false>. Both the iterator and const_iterator overloads are affected.

Steps to reproduce

#include<interval-tree/interval_tree.hpp>usingnamespacelib_interval_tree;intmain()
{
using Interval = interval<int, closed>;
interval_tree<Interval> tree;
tree.insert(Interval{1, 5});
auto it = tree.overlap_find_next_in_subtree(
tree.begin(),
Interval{2, 3}
);
(void)it;
}

Compile with:

g++ -std=c++17 -Iinclude repro.cpp

Expected: the call compiles and returns an iterator to an overlapping interval.

Actual: compilation fails because overlap_find_i_ex is called with three arguments instead of two.

Suggested fix

Dispatch to the appropriate template specialization:

auto* result = exclusive
? overlap_find_i_ex<true>(from.node_, ival)
: overlap_find_i_ex<false>(from.node_, ival);
return iterator{result, this};

Apply the same change to the const_iterator overload and add tests for both values of exclusive.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions