This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Passing template class by reference


How do you pass a template class object by reference? As an example:

Say we have a namespace util  and

Namespace NewName
{
Class A
{
                SomeRoutine(util::CSomeUtilClass<CDataWrapperClass>
&msg);
};
}

Now when I call this method in a cpp file gcc complains that 
"error: with
NewName::A::SomeRoutine(util::CSomeUtilClass<CDataWrapperClass>&)'
And
Error: no matching function for call to
'NewName::A::SomeRoutine(util::CSomeUtilClass<CDataWrapperClass>&)'

Any idea how I can get around this?  I can remove the '&' from method
and have it compile just fine!  Any help would be greatly appreciated...

Also I've another strange problem with nested classes:

So let say we have

Class SemaphoreC
{
...
};


Class data
{
...
};

Namespace util
{

	tempate <class T>
	Class SmartPtr
	{
	...
	};

	 
	template <class T>
	class someTemplate
	{
	Public:
		GetSem(){return m_sem);
	Private:
		SemaphoreC m_sem;
	};

}

class A
{
	Class Nested
	{
                Class A *a_ptr;
	};

	Private:
	TrytogetSem();
	util::someTemplate< util::SmartPtr<data> > var;
};

Now when the GetSem is called from A::TrytogetSem() ie.

A::TrytogetSem()
{
		Declared in class Nested    declared in class A
member of someTemplate
			|				|
|
			|				|
|
  SemaphoreC s = a_ptr->			var.
GetSem();

}

And gcc complains that it's unable to convert void * to LONG?  I can
declare 's' as void * and the error disappears

Regards,


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]