Error using template class instance as member of template class.

I came across the following errors while working on my personal project (simplified):
1
2
3
4
...: error: type ‘CustomMemberFunction<NumericRange<BoundType, CompareType> >’ is not derived from type ‘NumericRange<BoundType, CompareType>’
... : error: expected ‘;’ before ‘minValidator’
... : error: type ‘CustomMemberFunction<NumericRange<BoundType, CompareType> >’ is not derived from type ‘NumericRange<BoundType, CompareType>’
... : error: expected ‘;’ before ‘maxValidator’


And the relevant code involved, in summary is:
NumericRange.h
1
2
3
4
5
6
7
8
9
template <typename BoundType, typename CompareType> class NumericRange : public Validator
{
private:			
	///Validator used to validate min values.
	CustomMemberFunction<NumericRange<BoundType, CompareType> >::Ptr minValidator;
	///Validator used to validate max values.
	CustomMemberFunction<NumericRange<BoundType, CompareType> >::Ptr maxValidator;
     ...
};


CustomMemberFunction.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
template <class InstanceType> class CustomMemberFunction : public Validator
{
private:
	///Pointer to the object that the member function belongs to.
	InstanceType* object;
	/** Pointer to a validation function, can be a static function.
	* \remark The function should throw an exception if validation fails.
	*/
	void (InstanceType::*validatorMethod)(PropertyBase* const property, const Poco::DynamicAny& newValue);

public:
	///Typedefine for Validator SharedPtrs.
	typedef Poco::SharedPtr<CustomMemberFunction<InstanceType> > Ptr;
    ...
};


To me, the error message makes absolutely no sense. CustomMemberFunction should not inherit from NumericRange, and I use the class with a non-template argument elsewhere and it works fine.

If you need more information please let me know. I am working on Ubuntu 10.10. I have a gut feeling that the fact that I'm using a template class as a template argument could be the source of the problem, but I'm unsure how I could get around this and still have it work the way I want.

Any help will be greatly appreciated.
That's just confusing wording on part of the GCC compiler - You need to make use of the keyword typename


1
2
3
4
5
6
7
8
9
template <typename BoundType, typename CompareType> class NumericRange : public Validator
{
private:            
    ///Validator used to validate min values.
    typename CustomMemberFunction<NumericRange<BoundType, CompareType> >::Ptr minValidator;
    ///Validator used to validate max values.
    typename CustomMemberFunction<NumericRange<BoundType, CompareType> >::Ptr maxValidator;
     ...
};
That fixed it. The error message is particularly unhelpful.

After seeing the solution I remembered that I actually encountered and solved this same problem about 6 months ago. Real life got into the way after that and the project was put on hold and the original problem and solution forgotten.
Topic archived. No new replies allowed.