Partial Specialization as a friend ...?

B

Belebele

I would like to have as friend of a class a partial specialization of
a class template. Is that allowed? The code below fails to compile.
How could I achieve that effect?

template <typename> class Friend {};

class HasFriend {

template <typename T>
friend class Friend<T*>;

};
 
V

Victor Bazarov

Belebele said:
I would like to have as friend of a class a partial specialization of
a class template. Is that allowed? The code below fails to compile.
How could I achieve that effect?

template <typename> class Friend {};

class HasFriend {

template <typename T>
friend class Friend<T*>;

};

Prohibited. 14.5.3/9 (14.5.4/8 in the new draft).

You can make the entire template a friend.

V
 
B

Belebele

Prohibited. 14.5.3/9 (14.5.4/8 in the new draft).
Well, I tried ... By the way, how can I get to those sections (in the
Standard?) using the references that you provide? I guess I have
unsuccessfully tried a couple of times to get to them.
You can make the entire template a friend.
Perfection is the enemy of the good.

Thanks.
 
V

Victor Bazarov

Belebele said:
Well, I tried ... By the way, how can I get to those sections (in the
Standard?) using the references that you provide? I guess I have
unsuccessfully tried a couple of times to get to them.

FAQ 6.13 (the draft information is old). The most recent draft of
the upcoming standard document is found on the Committee web site,
http://www.open-std.org/jtc1/sc22/wg21/

V
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top