I began to use templates a few weeks ago, and I’m having trouble using it.
I got this error :
Freestyle/_gl/../_convection_selective/Definitions.h:153:9: error: ‘Node_handle’ in ‘Point_set {aka struct Kd_tree_patch > >*, My_point_property_map, CGAL::Search_traits > >, const double*, Construct_coord_iterator> > >}’ does not name a type
while compiling this code:
“Definitions.h”:
#include "Kd_tree_patch.h"
[...]
template <class SearchTraits, class Splitter_= CGAL::Sliding_midpoint<SearchTraits>, class UseExtendedNode = CGAL::Tag_true > class Kd_tree_patch; //forward declaration
typedef Kd_tree_patch<Search_traits> Point_set;
typedef Point_set::Node_handle Node_handle;
“Kd_tree_patch.h”:
template <class SearchTraits, class Splitter_=Sliding_midpoint<SearchTraits>, class UseExtendedNode = Tag_true >
class Kd_tree_patch {
[...]
typedef Kd_tree_node<SearchTraits, Splitter, UseExtendedNode > Node;
typedef typename Compact_container<Node>::iterator Node_handle;
};
Why Node_handle isn’t considered as a type yet ?
Thanks for your help.
You cannot forward declare nested types, which means that to be able to use the nested type
Node_handle, the templateKd_tree_patchmust be defined before the typedef. Once you fix that, you will also need to instruct the compiler that it is a type through the use oftypename: