This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/20011] Templates and cyclic dependencies
- From: "jmoro at latentzero dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 17 Feb 2005 10:47:57 -0000
- Subject: [Bug c++/20011] Templates and cyclic dependencies
- References: <20050216180452.20011.jmoro@latentzero.com>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From jmoro at latentzero dot com 2005-02-17 10:47 -------
I am sorry but that is not good enough. If I read correcly, you recommend that
to solve the problem with my template function member of a class is ... not to
use template functions as members of the class.
My example was indeed simple and you could get the template out of the class but
if I alter slightly B.h, you can see why I want g() to be a member of the class.
I can obviouly come up with solutions where I don't use member template
functions or even where I don't use templates at all but what I want to know is
how you are supposed to deal with this problem at hand.
What is the recommended way, with gcc 3.4, to deal with template methods and
circular dependencies?
Again, when I read a good C++ book, the solution is to use the export keyword
but GCC does not support it.
///////
// B.h
///////
class A;
class B
{
public:
B(){}
~B(){}
template <class T> int g( T t )
{
A * a = GetA();
return ( a->getInt() + t );
}
int getInt() const
{
return 2;
}
private:
A * GetA();
};
--
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |UNCONFIRMED
Resolution|INVALID |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20011