Re: On the use of namespaces to manage versions in C++
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