MESSAGE
DATE | 2011-06-05 |
FROM | Ruben Safir
|
SUBJECT | Subject: [NYLXS - HANGOUT] (fwd) Re: Anonymous namespace
|
-- forwarded message -- Path: reader1.panix.com!panix!bloom-beacon.mit.edu!micro-heart-of-gold.mit.edu!nntp.club.cc.cmu.edu!feeder.erje.net!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: Victor Bazarov Newsgroups: comp.lang.c++ Subject: Re: Anonymous namespace Date: Fri, 03 Jun 2011 09:44:29 -0400 Organization: A noiseless patient Spider Lines: 20 Message-ID: References: <03464db0-e118-463c-9834-171dab457e42-at-h9g2000yqk.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Fri, 3 Jun 2011 13:44:30 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="mfoyPVXLF0MtM1ZkAsRgyQ"; logging-data="22668"; mail-complaints-to="abuse-at-eternal-september.org"; posting-account="U2FsdGVkX1/ld1vdKrwNO8VXsc0DWoyN1pYknQk3LVw=" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.17) Gecko/20110414 Thunderbird/3.1.10 In-Reply-To: <03464db0-e118-463c-9834-171dab457e42-at-h9g2000yqk.googlegroups.com> Cancel-Lock: sha1:1tJdgbnJLXLDLsPO8FFaLAFSWmo= Xref: panix comp.lang.c++:1085973
On 6/3/2011 4:08 AM, gwowen wrote: > On Jun 3, 3:54 am, r...-at-zedat.fu-berlin.de (Stefan Ram) wrote: >>> What is the point of the anonymous namespace. >> >> Names can be hidden from the linker (from other translation >> units), even if they should have external linkage. > > Can someone give the benefits of external-but-unlinkable anon- > namespace variables (or functions) against old-school internal linkage > file-scope "static" variables and functions.
The Standard prohibits the use of names with no linkage or names with internal linkage as template arguments. Only objects with external linkage are allowed. Hence you can't use a function declared 'static' or a local type as a predicate in 'std::sort', for instance, or as the functor in 'std::for_each', and so on.
V -- I do not respond to top-posted replies, please don't ask -- end of forwarded message --
|
|