http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45942

           Summary: class will not get friends with another class
           Product: gcc
           Version: 4.4.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: michiel...@aim.com


In my current project, the construction of template class classB works well
when friend class declarations are replaced by making classA public.

With attempt 1, the compiler gives an error message, but not before
instantiation.

With attempt 2, the compiler gives an error message immediately, but an
incorrect one.


g++ (GCC) 4.4.1 20090725 (Red Hat 4.4.1-2)
Copyright (C) 2009 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


template <class T, int C> class classA;

template <class T, int C, classA<T,C> &instanceA> class classB;

template <class T, int C> class classA
{

  // error message on instantiation: too few template parameters (1 < 3)
  template <classA &instanceA> friend class classB;

  // incorrect error message: partial specialization claimed but not apparent 
  // template <classA &instanceA> friend class classB<T,C,instanceA>;

private:
  int for_use_by_classB;

};

template <class T, int C, classA<T,C> &instanceA> class classB
{

  classB (int i) { instanceA.for_use_by_classB = i; }

};

// instantiation
// template class classA<char,128>;

Reply via email to