Templates And Errors in regards to typedefs and inner classes.

In short, I'm trying to write a Binary Search Tree. I have a template class which includes the function definitions in an .inl file. for the purposes of keeping the code clean. One problem I'm experiencing is getting the Iterator (Which is an inner-class to the BST ) working properly with templates. Take the following as an example:

1
2
3
4
5
6
7
8
9
10
11
12
template < typename TComparable, typename TValue >
	typename SearchTree< TComparable, TValue >::Iterator SearchTree< TComparable, TValue >::begin( TreeIterator::IteratorFocus f ) const
	{
		typename SearchTree< TComparable, TValue >::Iterator ret( 0, f ); 
		return ret;
	}

	template < typename TComparable, typename TValue >
	typename SearchTree< TComparable, TValue >::Iterator SearchTree< TComparable, TValue >::end( TreeIterator::IteratorFocus f ) const
	{
		return typename SearchTree< TComparable, TValue >::Iterator( mNodeCount, f );
	}


This produces the following: Error 18 error C2059: syntax error : ')' c:\programming\c++\git\escalator\engine\engine\searchtree.inl 121

Where "TreeIterator" is just a typedef for SearchTree< TComparable, TValue > in the header file.

Other issues I am having include getting the nested Iterator class to conform to STL standards. I've friended it in the BST class, and vice-versa for private member access, and...well, I'll post the header file.

Basically, what I need is someone to tell me what the hell I'm doing wrong, and what I can do rectify it. I'll pastebin the rest of the .inl file for the sake of cleanliness.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
template < typename TComparable, typename TValue > 
	class SearchTree
	{
	public:
		class Iterator;
	protected:
		struct Node;
		typedef typename Node TNode;
		typedef typename SearchTree< TComparable, TValue >::Iterator TreeIterator;
	public:
		SearchTree( void );
		~SearchTree( void );
	public:
		TValue find( const TComparable& k );
		TValue find( int32_t index );
		TValue find( const Iterator& pIter );
		
		TreeIterator begin( TreeIterator::IteratorFocus f ) const;
		TreeIterator end( TreeIterator::IteratorFocus f ) const;
	
		void insert( const TComparable& k, const TValue& v );
		void insert( const Iterator& pIter );

		friend class Iterator;
		friend class TNode;
	protected:
		int32_t mNodeCount;
		TNode* mRoot;
	public:
		class Iterator 
		{
		protected:
			typename typedef SearchTree< TComparable, TValue > Tree;
		public:
			enum IteratorFocus { Rightmost, Leftmost };
			Iterator( void );
			Iterator( int32_t position, IteratorFocus focus );
			~Iterator( void );
			inline TNode* getCurrent( void ) const 
			{ return mCurrentNode; }
			inline int32_t getPosition( void ) const
			{ return mPosition; }
			inline TNode* operator->( void ) const 
			{ return mCurrentNode; }
			int32_t operator++( void );
			bool operator==( const Iterator& pIter );
			bool operator!=( const Iterator& pIter );
		protected:
			int32_t getNumStepsLeftToLeaf( void );
			int32_t getNumStepsRightToLeaf( void );
			bool isLeafNode( const Node*& n );
			bool isInternalNode( const Node*& n );
			bool inOrderTraverse( Node* n );
			TValue treeSearch( Node* n, const TComparable& k );
		protected:
			TNode* mCurrentNode;
			int32_t mIterPosition;
			IteratorFocus mFocus;
			friend class TNode;
			friend class SearchTree< TComparable, TValue >;
		};
	protected:
		struct Node
		{
		public:
			Node( void ) : mParent( NULL ), mLeftChild( NULL ), mRightChild( NULL )
			{}
			~Node( void )
			{
				if ( mParent ) delete mParent;
				if ( mLeftChild ) delete mLeftChild;
				if ( mRightChild ) delete mRightChild;
			}
			int32_t index;
			TComparable Key;
			TValue Value;
			TNode* mParent;
			TNode* mLeftChild;
			TNode* mRightChild;
			inline bool operator== ( Node* n )
			{ return ( n->Key == Key ) && ( n->Value == Value ); }
		};
	};



Source File
http://pastebin.com/09uaMMWT

Errors
http://pastebin.com/tnDLWAZq

Thank you to anyone who can help.
Topic archived. No new replies allowed.