public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/45942] New: class will not get friends with another class
@ 2010-10-08 13:42 MichieldeB at aim dot com
  2010-10-08 14:41 ` [Bug c++/45942] " redi at gcc dot gnu.org
                   ` (14 more replies)
  0 siblings, 15 replies; 16+ messages in thread
From: MichieldeB at aim dot com @ 2010-10-08 13:42 UTC (permalink / raw)
  To: gcc-bugs

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: unassigned@gcc.gnu.org
        ReportedBy: MichieldeB@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>;


^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2010-10-09 18:19 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-08 13:42 [Bug c++/45942] New: class will not get friends with another class MichieldeB at aim dot com
2010-10-08 14:41 ` [Bug c++/45942] " redi at gcc dot gnu.org
2010-10-08 14:46 ` redi at gcc dot gnu.org
2010-10-08 14:51 ` MichieldeB at aim dot com
2010-10-08 14:58 ` MichieldeB at aim dot com
2010-10-08 15:03 ` paolo.carlini at oracle dot com
2010-10-08 15:08 ` redi at gcc dot gnu.org
2010-10-08 15:12 ` MichieldeB at aim dot com
2010-10-08 15:36 ` redi at gcc dot gnu.org
2010-10-08 15:43 ` MichieldeB at aim dot com
2010-10-08 15:59 ` redi at gcc dot gnu.org
2010-10-08 16:09 ` MichieldeB at aim dot com
2010-10-09 13:02 ` MichieldeB at aim dot com
2010-10-09 13:38 ` MichieldeB at aim dot com
2010-10-09 18:08 ` redi at gcc dot gnu.org
2010-10-09 18:19 ` redi at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).