Afficher un message
Vieux 15/10/2007, 16h09   #6
CrazyJohn
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Question about Unnamed Namespace

Dude, thanks for your reply, I really appreciate it. I was just about
to tell myself I understand this, but what you said confuses me
again.

> That's not quite true. What it means is that they cannot be
> names in other TU's. If your compiler supports export, they can
> be seen and used by template instantiations, when the template
> has been defined in another TU. (That is, in fact, part of the
> reason why the anonymous namespace was invented.)
>
> Note for example:
>
> template< int& ri > class T{} ;
>
> static int i1 ;
> T< i1 > t1 ; // Illegal...
>
> namespace { int i2 ; } ;
> T< i2 > t2 ; // Legal...


I understand why using "i1" is illegal, but would you explain why
using unnamed namespace is legal again? And what is this "export"
thing btw......

Thanks in advance.

>
> If T were actuallly exported, and contained code, that code
> could refer to i2 by means of its argument ri. Even though the
> code was in another translation unit. This is not possible with
> static.
>
> --
> James Kanze (GABI Software) email:james.ka...@gmail.com
> Conseils en informatique orientée objet/
> Beratung in objektorientierter Datenverarbeitung
> 9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34



  Réponse avec citation
 
Page generated in 0,06400 seconds with 9 queries