Topic: template functions as restricted friends of template classes
Author: Alexandre Oliva <oliva@dcc.unicamp.br>
Date: 1998/08/14 Raw View
Hi!
Can anyone think of a way to declare that a subset of the
specializations of a template function should have privileged access
to a specialization of a template class? I.e., given:
template <typename A, typename B>
void foo();
template <typename C>
class bar {
FRIEND_DECL;
};
What should FRIEND_DECL expand to, if I want foo<A,B>, for all B, to
have privileged access to bar<A>?
It can't be:
template <typename A, typename B> friend void foo();
because it would allow foo<void,void> to access private members of
bar<int>. OTOH, declaring:
template <typename B> friend void foo<C,B>();
would look like partial specialization, but there's no such thing as
partial specialization of function templates. Is this declaration
valid? Does it have the intended effect?
--
Alexandre Oliva
mailto:oliva@dcc.unicamp.br mailto:aoliva@acm.org
http://www.dcc.unicamp.br/~oliva
Universidade Estadual de Campinas, SP, Brasil
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]