This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: STL and Mozilla XPCOM


On February 19, 2002 04:21 pm, Tobias Oberstein wrote:
> i'm having a problem with a "&*something" idiom in the GNU STL,
> which occurs here..
>
> [toberste@bluebox g++-3]$ grep -r "\&\*" .
> ./stl_raw_storage_iter.h:    construct(&*_M_iter, __element);
> ./stl_construct.h:    destroy(&*__first);
> ./stl_uninitialized.h:      construct(&*__cur, *__first);
> ./stl_uninitialized.h:      construct(&*__cur, *__first);
> ./stl_uninitialized.h:      construct(&*__cur, __x);
> ./stl_uninitialized.h:      construct(&*__cur, __x);
> [...]
> nsCOMPtr is a smart pointer class, which makes interfaces
> a lot safer ..
> [...]
> the problem is, that nsCOMPtr makes operator&() _private_
> to avoid some leaks caused by automatic casts.
>
> unfortunately, the GNU STL implementation dislikes this: it
> uses a "&*something" idiom in some places .. to be exact -
> there are 6 occurencesas as listed above.

While the rationale behind the idiom has already been explained, I'd 
like to point out that your problem is that your smart pointer violates 
the requirements of a type that can be stored in an STL container.

In particular, it does not satisfy the CopyConstructible requirement.  
In section 20.1.3 of the standard, Table 30, line 4 explicitly states 
that for a value t of type T, the expression &t must yield T*, the 
address of t.

The GNU STL implementation is being standard-compliant when it
fails to compile your code.  If you enabled the concept checking 
extension, you should receive error messages to that effect.

-- 
Stephen M. Webb


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]