🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #2578

Re: [Q] Templates in namespaces?

#2578
From: Sean A Corfield
Date: Mon, 13 Nov 1995 16:06
36 lines
2066 bytes
In article <481d4h$fr7@dingo.cc.uq.oz.au>,
Tony Coates <coates@mailbox.uq.oz.au> wrote:

|> Can anyone tell me (hope this isn't a FAQ ...) what the status is on
|> whether templates can be placed in namespaces?  My understanding was
|> this was a matter of recent debate, with some compilers currently
|> making all template definitions global.  For my own part, I think it
|> would be a sad decision to make template definitions compulsorily
|> global, and hence effectively downgrade template definitions with
|> respect to non-template definitions.

Templates can indeed be placed in namespaces. The current WP says that
specialisations of such templates must also go inside the same namespace:

  namespace Lib {
    template<typename T> class X { };
  }

  // must reopen namespace to define specialisation
  namespace Lib {
    template<> class X<int> { };
  }

[note: the example uses recently adopted syntax 'typename' as an
alternative to 'class' and 'template<>' to introduce a specialisation]

The other major issue which has an impact on templates & namespaces is name
injection -- the committee are debating this subject at the moment.

Sean A. Corfield
Object Consultancy Services -- voting member of X3J16
C++ - Beyond the ARM http://uptown.turnpike.net/~scorf/cplusext.html
---
[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Technical Details
Message-ID: <ACCCFC90966811A2B6@corf.demon.co.uk>
Path: arc1-ca.pugleaf.net!in2.uu.net!bounce-back
References: <481d4h$fr7@dingo.cc.uq.oz.au>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!in2.uu.net!bounce-back
Date: 13 Nov 95 16:06:58 GMT
Approved: fjh@cs.mu.oz.au
From: Sean A Corfield <sean@corf.demon.co.uk>
Newsgroups: comp.std.c++
Subject: Re: [Q] Templates in namespaces?
X-Original-Date: Mon, 13 Nov 1995 13:45:52 +0000
Organization: OCS
Message-ID: <ACCCFC90966811A2B6@corf.demon.co.uk>
References: <481d4h$fr7@dingo.cc.uq.oz.au>
X-Auth: PGPMoose V1.1 PGP comp.std.c++
 iQBFAgUBMKdtbOEDnX0m9pzZAQF3ZgF8CaTU4tPqqmu/LTi7UCvZ18stKUoisLC2
 pgf/Z9YqlMqX+RTr18seEiEQMrwJ57gv
 =YR+t