Skip to main content
gamedev.net
🔒 Locked

(VS .NET) C2091: function returns function

Started by rypyr 3 replies 3.3k views
Original Post
rypyr
rypyr
I'm getting the above error on the following line of code:
	template< typename T > struct DXComponentZMapper
	{
		typedef unsigned int KeyType;
		const KeyType getKey()(const T& o)
		{ return o->getZOrder(); } // Compiler error here...
	};
  
which is declared in this:
	TSortTree< DXComponent*, DXComponentZMapper > CompTree;
  
where TSortTree has the following declaration:
	template<	typename T
		, template< class > class MappingPolicy = TrivialKeyMapper
		, template< class > class AllocatorPolicy = StandardNodeAllocator
		, template< class > class BalancerPolicy = NeverTreeBalancer >
	class TSortTree {
		// ....
	};
  
Does anybody know why this happens? Does it have anything to do with including STL ? Thanks a lot, Jeff Edit: Fixed the angle brackets...grr [edited by - rypyr on February 3, 2004 10:28:56 AM]
Mathematix
Mathematix
Exactly what is says on the tin. You''re dereferencing the function. Change it to

return o.getZOrder();
rypyr
rypyr
Nope, as the code indicates, it is constructed with a pointer to a DXComponent, not a DXComponent object in this line:

TSortTree< DXComponent*, DXComponentZMapper > CompTree;

Thus, the code o->getZOrder() should be correct.
rypyr
rypyr
ARGH! What a ridiculous typo:

const KeyType& getKey()(const T& o)

should have been

const KeyType& getKey(const T& o)

The reason for such stupidity is that I used to have this function as operator() and changed it to a named function!

Regards,
Jeff
Mathematix
Mathematix
Well done.

[edited by - mathematix on February 3, 2004 11:09:34 AM]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.