• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: On the use of namespaces to manage versions in C++
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: On the use of namespaces to manage versions in C++


  • Subject: Re: On the use of namespaces to manage versions in C++
  • From: Steve Checkoway <email@hidden>
  • Date: Thu, 8 Feb 2007 02:16:59 -0800


On Feb 6, 2007, at 4:33 PM, James Widman wrote:

On Feb 3, 2007, at 7:31 PM, Steve Checkoway wrote:
A good reason, but then Apple's gcc used #import when it was deprecated in FSF gcc (a cursory glance at google tells me that it might be undeprecated after a patch from Apple).

And yet, the reason I gave is still compelling. (:

Yes it is.

Why not just follow what cxxabi.h does? Everything is in namespace __cxxabiv1 and then at the end of the header it has
namespace abi = __cxxabiv1;


If this ever changes, then older code will still link to the proper version.

If you want to ensure that the users of your library can never re- open your namespace in a version-independent way (and therefore, if you also want to ensure that they can never (in a version- independent way) declare partial or explicit specializations of your class templates or explicit specializations of your function templates), then I see nothing wrong with your suggestion. But the ADC article's example did involve an explicit specialization of a library class template from within user code.

I had no idea that namespace aliases couldn't be used that way. It seems like a silly artificial restriction. The error I get is "error: namespace alias ‘foo’ not allowed here, assuming ‘foov1’" so I'd say it's rather obvious that g++ knew exactly what namespace I meant.


It looks like the grammar for a namespace definition is pretty explicit on this one:

namespace-name -> original-namespace-name | namespace- alias
original-namespace-name -> identifier
...
extension-namespace-definition -> namespace original-namespace-name { namespace-body }
...


It's in 7.3.1.1 [namespace.def] of ISO/IEC 14882:1998(E). No rationale is given that I can see. This has clearly been considered <http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1526.txt>.

--
Steve Checkoway



Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >On the use of namespaces to manage versions in C++ (From: James Widman <email@hidden>)
 >Re: On the use of namespaces to manage versions in C++ (From: Steve Checkoway <email@hidden>)
 >Re: On the use of namespaces to manage versions in C++ (From: James Widman <email@hidden>)

  • Prev by Date: Re: Bizarre x86 segment layout problem causing select() slowdown: solved, sort of
  • Next by Date: Code for searching sound files
  • Previous by thread: Re: On the use of namespaces to manage versions in C++
  • Next by thread: Bizarre x86 segment layout problem causing select() slowdown
  • Index(es):
    • Date
    • Thread