Skip to content

Documentation is incorrect #34

@phlummox

Description

@phlummox

The example in the README:

  vector<Interval<T> > intervals;
  T a, b, c;
  intervals.push_back(Interval<T>(2, 10, a));
  intervals.push_back(Interval<T>(3, 4, b));
  intervals.push_back(Interval<T>(20, 100, c));
  IntervalTree<T> tree;
  tree = IntervalTree<T>(intervals);

doesn't compile.

E.g. wrap it in a function as follows, and try compiling:

template<typename T>
void foo() {
  vector<Interval<T> > intervals;
  T a, b, c;
  intervals.push_back(Interval<T>(2, 10, a));
  intervals.push_back(Interval<T>(3, 4, b));
  intervals.push_back(Interval<T>(20, 100, c));
  IntervalTree<T> tree;
  tree = IntervalTree<T>(intervals);
}

Problems include:

  • the Interval and IntervalTree templates take two parameters, not one - Interval<T> and IntervalTree<T> are not correct. (Presumably it should be something like Interval<size_t, T> etc., like in interval_tree_test.cpp.

  • the call to the constructor doesn't compile. If you call foo<bool>() and compile, you'll get errors along the lines of (summarizing):

    error: no matching conversion for functional-style cast from 'vector<Interval<size_t, bool> >' (aka 'vector<Interval<unsigned long, bool> >') to 'IntervalTree<size_t, bool>' (aka 'IntervalTree<unsigned long, bool>')
    
    // ...
    
    ./intervaltree/IntervalTree.h:92:5: note: candidate constructor not viable: no known conversion from 'vector<Interval<size_t, bool> >' (aka 'vector<Interval<unsigned long, bool> >') to 'IntervalTree<unsigned long, bool>::interval_vector &&' (aka 'vector<Interval<unsigned long, bool> > &&') for 1st argument
    

From the interval_tree_test.cpp test file, it looks like the constructor now takes an initializer list.

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