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]

STL and Mozilla XPCOM


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);

.. maybe someone could explain the rationale behind this idom?

background:

i'd like to use STL containers to hold smart pointers of
interfaces used in XPCOM, the Mozilla component framwork.

e.g.
std::vector<nsCOMPtr<nsISupports> > vec_;

which declares vec_ as a container holding interfaces
(nsISupports is like MS IUnknown, the mother of all)

nsCOMPtr is a smart pointer class, which makes interfaces
a lot safer ..

http://lxr.mozilla.org/seamonkey/source/xpcom/glue/nsCOMPtr.h
http://lxr.mozilla.org/seamonkey/source/xpcom/glue/nsCOMPtr.cpp

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.

i want to wrap this up in a adapter class STL<->nsCOMPtr,
but i'd feel much safer if i'd understood the rationale behind
the idiom?

thanks for any hints,
Tobias







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