This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Templated friends?


Hi!

Are we supposed to accept something like

template <class X>
class A {
        void bar() const;
        template <class Y>
        void foo(const A<Y>& a) const {
                a.bar();
        }
        template <class Y>
        friend class A;
};

int main(int argc, char **argv)
{
        A<int> a;
        A<double> b;
        a.foo(b);
        return 0;
}

The above gives

templatedfirends.cpp:5: error: `void A<X>::foo(const A<Y>&) const [with Y
= double, X = int]' is private
templatedfirends.cpp:16: error: within this context

which is incorrect(?)

Thanks, Richard.

--
Richard Guenther <richard.guenther@uni-tuebingen.de>
WWW: http://www.tat.physik.uni-tuebingen.de/~rguenth/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]