Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #14979 > unrolled thread
| Started by | Евгений Щербина <ebeholder@gmail.com> |
|---|---|
| First post | 2012-03-18 22:04 -0700 |
| Last post | 2012-03-19 05:11 -0700 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.lang.c++
friend template function of template class Евгений Щербина <ebeholder@gmail.com> - 2012-03-18 22:04 -0700
Re: friend template function of template class ebeholder@gmail.com - 2012-03-19 05:11 -0700
| From | Евгений Щербина <ebeholder@gmail.com> |
|---|---|
| Date | 2012-03-18 22:04 -0700 |
| Subject | friend template function of template class |
| Message-ID | <228cae3c-5293-4599-ba11-e30963907fb4@z17g2000yqf.googlegroups.com> |
Hi folks!
I have the following simplified code:
template <class T>
class A
{
public:
template <class U>
static U foo(T* p)
{
p;
return U();
}
};
class B
{
/*template <class T>
template <class U>
friend U A<T>::foo<U>(T*);*/
friend B A<B>::foo<B>(B*);
B()
{}
public:
};
...
A<B>::foo<B>(nullptr);
And it works quite well. But the things that I've not managed to do
are commented:
/*template <class T>
template <class U>
friend U A<T>::foo<U>(T*);*/
I don't know what the syntax I should use to make it works. So I need
to generalize my friend declaration to all possible types. I've tried
quite a few variants of syntax but had no success. Could some one
point me out what should I write instead of my commented code to make
it works? Thanks!
[toc] | [next] | [standalone]
| From | ebeholder@gmail.com |
|---|---|
| Date | 2012-03-19 05:11 -0700 |
| Message-ID | <22353159.4946.1332159092403.JavaMail.geo-discussion-forums@yniz5> |
| In reply to | #14979 |
Answer is there: http://stackoverflow.com/questions/9758757/friend-template-function-of-template-class
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.c++
csiph-web