www.digitalmars.com         C & C++   DMDScript  

c++ - C++ Compiler Bug (template friend in namespace)

Hi there,

Here's the simplified code:

  namespace N
  {
    template <class T>
    class B;
  }

  class A
  {
    template <class T>
    friend
    class N::B;
  };

Here's the error:

  Error: ';' expected following declaration of class template 'N'

Here's the list of other compilers that I have tested the code with:

  - Visual C++ 7.1 (2003);
  - Borland C++ 5.5.1 (1998), 5.6.0 (2000), 5.9.0 (2007)
  - Comeau C++ 4.4.3 "TryItOut" (2006?).

Here's the original (simplified) code, from Boost.Exception
(file boost/exception/exception.hpp, latest revision from SVN, 2008-
09-09):

  namespace boost
  {
    namespace exception_detail
    {
      template <class>
      struct get_info;
    }

    class exception
    {
      template <class>
      friend struct exception_detail::get_info;
    };
  }

I would like to kindly ask anyone reading this who can see
a work-around to post a hint. :)


Thank you for your time !

--
Yours truly,
Adder
Sep 09 2008