CComBSTR, std::endl and stack overflow

D

Dilip

I am not sure if this is a VC++/ATL related problem or with the way
std::endl works, so I have cross-posted this to 2 newsgroups. Please
trim appropriately if you feel this is OT for c.l.c++

I have a STL map that looks like this:

typedef std::map<ATL::CComBSTR, SomeStructure* ss> structMap;
structMap actualMap;

CComBSTR is just a wrapper over BSTR found in DCOM land. My question
is, I am iterating through this map and printing all the values to a
file like so:

ofstream ofs(...);
for (structMap::const_iterator itr = actualMap.begin(); itr !=
actualMap.end(); ++itr)
{
CComBSTR const& thekey = itr->first;
// use VC++ macro hocus-pocus to convert a BSTR to const char*
ofs << W2A(thekey.m_str);
ofs << std::endl;
}

If I comment out the first 2 lines inside the loop, everything works
fine (obviously I am priting the other members of SomeStructure).
Uncommenting them causes a stack overflow error deep in the bowels of
std::endl when it tries to flush the contents to the file. Is there
any known problems when W2A is called in a tight loop? My map can have
literally millions of entries.

I am sure I must be missing something obvious.. its been a long day and
I have been tearing my hair over this. any help will be greatly
appreciated.

thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top