This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Template Methods.
- To: egcs-bugs at cygnus dot com
- Subject: Template Methods.
- From: Erez Louidor Lior <s3824888 at techst02 dot technion dot ac dot il>
- Date: Sat, 10 Oct 1998 19:20:52 +0300
I was working with templates and discovered some strange behaviour
from egcs.
I was using the October 5th snapshot.
1. How can I declare a template function with two parameters to be a
friend of a class C, in such a way that only one of the template
parameters
is fixed, and the other is a template argument. I tried the following
but
it did not work:
template <typename T, typename S>
void foo();
class bar{
template <typename S>
friend void foo<S, int>();
};
egcs complained:
"templates2.cc:6: template-id `foo<S, int>' in declaration of primary
template"
2. How can I do the same with classes:
When I tried the following:
template <class T, class B>
class A{
};
class B{
template <class U>
friend class A<U, int>;
};
egcs complained:
"templates3.cc:7: partial specialization `A<U,int>' declared `friend'"
3. I'm not sure if I used the proper installation procedure to install
the
egcs snapshot.
In the INSTALL directory, I found a reference to the cygnus
web page but I couldn't find the wwwdocs there.
Since I don't have remote cvs, I couldn't check out those docs either.
Instead I used the same installation procedure that I used to build and
install the
1.1b release of egcs.
This may be inappropriate, since I did get a lot of warnings compiling
egcs.
Later, when I worked on compiling some piece of code of mine, I got the
following strange error messages from egcs:
test1.cc:72: instantiated from
`Handles::BasicHandle<Animal,Handles::NonIntrusive::Attachment>'
test1.cc:72: instantiated from `Handles::NonIntrusive::Handle<Animal>'
test1.cc:72: instantiated from here
handles.hh:127: previous declaration `template <class Type, template
<class> Attachment> Handles::HandleImp<Type,Attachment>'
handles.hh:127: used 2 template parameters instead of 137525512
Since my code is a bit large, I wanted to make sure first, that I
compiled egcs
correctly, before I simplify my code and sent a bug report about it.
eg++ -v:
Reading specs from
/usr/local/egcs-19981005/lib/gcc-lib/i586-pc-linux-gnulibc1/egcs-2.92.13/specs
gcc version egcs-2.92.13 19981005 (gcc2 ss-980609 experimental)
Thanks,
Erez.
--
----------------------------------------------------------------------
"The ships hung in the sky in much the same way that bricks don't."
-- Douglas Adams / The Hitchhiker "Trilogy".