public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c++/7308: template specialization in other namespace
@ 2002-12-19 18:38 bangerth
  0 siblings, 0 replies; 2+ messages in thread
From: bangerth @ 2002-12-19 18:38 UTC (permalink / raw)
  To: a9804814, gcc-bugs, gcc-prs, nobody

Old Synopsis: template-class member functions / namespace scope resolution in conjunction with template specialization
New Synopsis: template specialization in other namespace

State-Changed-From-To: open->analyzed
State-Changed-By: bangerth
State-Changed-When: Thu Dec 19 18:38:35 2002
State-Changed-Why:
    Problem 1 you describe is a well-known bug, namely that
    gcc does not presently implement two-stage name lookup.
    
    Problem 2 can be reduced to the following illegal code that
    gcc nevertheless compiles:
    ----------------------------
    namespace NS_1 {
      namespace NS_2 {
        template <typename T> struct C {
            void foo ();
        };
      }
    
      template <>
      void NS_2::C<int>::foo() {}
    }
    
    int main() {
      NS_1::NS_2::C<int> c;
    }
    -------------------------
    Specializations shall be _declared_ in the same namespace
    in which the general template is declared, if I understand
    correctly, i.e. there is at least a declaration in the inner
    namespace missing.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=7308


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

* Re: c++/7308: template specialization in other namespace
@ 2002-12-20  9:16 Martin Sebor
  0 siblings, 0 replies; 2+ messages in thread
From: Martin Sebor @ 2002-12-20  9:16 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR c++/7308; it has been noted by GNATS.

From: Martin Sebor <sebor@roguewave.com>
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: Re: c++/7308: template specialization in other namespace
Date: Fri, 20 Dec 2002 10:09:01 -0700

 bangerth@dealii.org wrote:
 > Old Synopsis: template-class member functions / namespace scope resolution in conjunction with template specialization
 > New Synopsis: template specialization in other namespace
 > 
 > State-Changed-From-To: open->analyzed
 > State-Changed-By: bangerth
 > State-Changed-When: Thu Dec 19 18:38:35 2002
 > State-Changed-Why:
 >     Problem 1 you describe is a well-known bug, namely that
 >     gcc does not presently implement two-stage name lookup.
 >     
 >     Problem 2 can be reduced to the following illegal code that
 >     gcc nevertheless compiles:
 >     ----------------------------
 >     namespace NS_1 {
 >       namespace NS_2 {
 >         template <typename T> struct C {
 >             void foo ();
 >         };
 >       }
 >     
 >       template <>
 >       void NS_2::C<int>::foo() {}
 >     }
 >     
 >     int main() {
 >       NS_1::NS_2::C<int> c;
 >     }
 >     -------------------------
 >     Specializations shall be _declared_ in the same namespace
 >     in which the general template is declared, if I understand
 >     correctly, i.e. there is at least a declaration in the inner
 >     namespace missing.
 
 The intent of that requirement is to prevent the declaration from
 changing the name of the explicit specialization by declaring it
 unqualified in another namespace. The code above is intended to
 be well-formed.
 
 This is what the wording is intended to disallow:
 
      namespace NS_1 {
        template <typename T> struct C {
           void foo ();
        };
        namespace NS_2 {
          template <>
          void C<int>::foo() {}   // error
        }
      }
 
      int main() {
        NS_1::NS_2::C<int> ci;    // error
        NS_1::C<int> ci;          // okay
      }
 
 Regards
 Martin
 


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

end of thread, other threads:[~2002-12-20 17:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-12-19 18:38 c++/7308: template specialization in other namespace bangerth
2002-12-20  9:16 Martin Sebor

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).