Re: CComBSTR, std::endl and stack overflow
Dilip <rdilipk@lycos.com> wrote:
On another note, what about Mr. Ozwirk's suggestion that I should not
be using CComBSTR in a map because STL containers have specific
requirements for classes used as key in terms of implementing operator
& ?
Formally, you are not allowed to put CComBSTR into any STL container.
Doing so invokes undefined behavior. In practice, with Dinkumware STL
implementation, you are likely to get away with it for most operations
on most containers. I know how to make it break with vector and deque,
but not with map.
Still, it's a good idea to be on the safe side and not introduce
non-standard behavior gratuitously. Just make it
std::map<CAdapt<CComBSTR>, SomeStructure* ss>
(btw, I don't take the address of my key
objects anyway.. so it might not even matter).
You don't, but the container may, internally.
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925