This is the mail archive of the gcc-bugs@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]

[Bug c++/49254] New: cannot declare member template as friend of class template


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

           Summary: cannot declare member template as friend of class
                    template
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Keywords: rejects-valid
          Severity: minor
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: redi@gcc.gnu.org


template<typename T>
  class outer
  {
    template<typename U>
      struct inner
      { };

    template<typename U>
      friend class outer;

    template<typename U>
      template<typename>
        friend class outer<U>::inner;

  public:

    outer() { }

  };

template class outer<void>;
template class outer<void>::inner<int>;


Gives this error:

priv2.cc: In instantiation of 'outer<void>':
priv2.cc:21:16:   instantiated from here
priv2.cc:5:14: error: 'template<class T> template<class U> struct
outer<T>::inner' is private
priv2.cc:5:14: error: within this context

I don't think the friend declaration is actually needed to allow inner<U> to
access outer<T>, but I think it is valid and should be accepted.  Comeau and
Clang accept it.


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