Click here to Skip to main content
15,608,936 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
The C++ (Preview - Features from the Latest C++ Working Draft (/std:c++latest)) code below generates the Visual Studio error below:

Quote:
goobar.cpp(62,103): error C2760: syntax error: unexpected token '>', expected ';'


Kindly advise how to modify the code so as to compile w/o error. Thank You Kindly - Cheerio

C++
  1  #include <functional>
  2  
  3  using namespace std;
  4  
  5  namespace tree
  6  {
  7  	template<typename nodePtrType, typename keyType, template<typename valueType> class referenceWrapperType >
  8  	struct data {};
  9  
 10  	template<typename dataType>
 11  	struct default_predicate
 12  	{
 13  		using data_type = dataType;
 14  	};
 15  
 16  	template<typename predicateType, typename sortType>
 17  	struct collect_functor
 18  	{
 19  		using this_type = collect_functor<predicateType, sortType>;
 20  		bool equal_to(const this_type& other) const { return true; }
 21  	};
 22  }
 23  
 24  template<class keyType, class valueType>
 25  struct cRedBlackTree
 26  {
 27  	using key_type = keyType;
 28  	using value_type = valueType;
 29  
 30  	struct node_ptr_type {};
 31  
 32  	template<typename dataType>
 33  	struct collect_sort {};
 34  
 35  	auto collect_reference() const
 36  	{
 37  		using data_type = tree::data<node_ptr_type, key_type, reference_wrapper>;
 38  		tree::default_predicate<data_type> predicate;
 39  		return collect(predicate);
 40  	}
 41  
 42  	template<typename predicateType>
 43  	auto collect(const predicateType& predicate) const
 44  	{
 45  		tree::collect_functor<predicateType, collect_sort<typename predicateType::data_type>> functor;
 46  		return functor;
 47  	}
 48  };
 49  
 50  struct cvalue {};
 51  using key_type = int;
 52  using value_type = cvalue;
 53  using tree_type = cRedBlackTree<key_type, value_type>;
 54  
 55  template<class treeType>
 56  auto collect_recursive(const treeType& tree)
 57  {
 58  	using tree_type = treeType;
 59  	using data_type = tree::data<typename tree_type::node_ptr_type, key_type, reference_wrapper>;
 60  	using predicate_type = tree::default_predicate<data_type>;
 61  	// for line below at column 103 : error C2760 : syntax error : unexpected token '>', expected ';'
 62  	using functor_type = tree::collect_functor<predicate_type, typename tree_type::collect_sort<data_type>>;
 63  	functor_type functor;
 64  	return functor;
 65  }
 66  
 67  template<class treeType>
 68  void check_tree_traversal(const treeType& tree)
 69  {
 70  	using tree_type = treeType;
 71  	auto iterative_user_data = tree.collect_reference();
 72  	auto recursive_user_data = collect_recursive(tree);
 73  	iterative_user_data.equal_to(recursive_user_data);
 74  };
 75  
 76  int main()
 77  {
 78  	cRedBlackTree<key_type, value_type> tree;
 79  	check_tree_traversal(tree);
 80  }


What I have tried:

I eliminated all using but that did not help. I prefer using as it makes the code much more readable.
Posted
Updated 7-Apr-21 6:16am
v2

Thank you for your kind assistance. I found that after eliminating use of using and redesigning so as to eliminate use of template template parameters the code now compiles w/o error. - Cheerio
 
Share this answer
 
Not sure if it is directly relevant, but take a look at the posts in this thread: use of dependent type name must be prefixed - C / C++ / MFC Discussion Boards[^].
 
Share this answer
 
Comments
Greg Utas 7-Apr-21 12:07pm    
It seems very likely, since types are being defined within a template.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900