@@ -191,11 +191,13 @@ namespace lib_interval_tree
191191 // ############################################################################################################
192192 template <
193193 typename numerical_type = default_interval_value_type,
194- typename interval_type_ = interval<numerical_type, closed>>
194+ typename interval_type_ = interval<numerical_type, closed>,
195+ typename derived = void >
195196 class node
196197 {
197198 protected:
198- using node_type = node<numerical_type, interval_type_>;
199+ using node_type =
200+ std::conditional_t <std::is_same<derived, void >::value, node<numerical_type, interval_type_>, derived>;
199201
200202 public:
201203 using interval_type = interval_type_;
@@ -217,7 +219,7 @@ namespace lib_interval_tree
217219 friend void increment_reverse (T& iter);
218220
219221 public:
220- node (node * parent, interval_type interval)
222+ node (node_type * parent, interval_type interval)
221223 : interval_{std::move (interval)}
222224 , max_{interval.high ()}
223225 , parent_{parent}
@@ -265,23 +267,23 @@ namespace lib_interval_tree
265267 /* *
266268 * Returns the parent node up the tree.
267269 */
268- node const * parent () const
270+ node_type const * parent () const
269271 {
270272 return parent_;
271273 }
272274
273275 /* *
274276 * Returns the left node (readonly).
275277 */
276- node const * left () const
278+ node_type const * left () const
277279 {
278280 return left_;
279281 }
280282
281283 /* *
282284 * Returns the right node (readonly).
283285 */
284- node const * right () const
286+ node_type const * right () const
285287 {
286288 return right_;
287289 }
@@ -338,9 +340,9 @@ namespace lib_interval_tree
338340 protected:
339341 interval_type interval_;
340342 value_type max_;
341- node * parent_;
342- node * left_;
343- node * right_;
343+ node_type * parent_;
344+ node_type * left_;
345+ node_type * right_;
344346 rb_color color_;
345347 };
346348 // ############################################################################################################
@@ -513,7 +515,7 @@ namespace lib_interval_tree
513515 throw std::out_of_range (" interval_tree_iterator out of bounds" );
514516 }
515517
516- typename value_type::interval_type* operator ->() const
518+ typename value_type::interval_type const * operator ->() const
517519 {
518520 if (node_)
519521 return node_->interval ();
0 commit comments