CComBSTR, std::endl and stack overflow

Discussion in 'C++' started by Dilip, Aug 8, 2006.

  1. Dilip

    Dilip Guest

    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!
     
    Dilip, Aug 8, 2006
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ishekar

    list<CComBSTR> error.

    ishekar, Aug 7, 2003, in forum: C++
    Replies:
    2
    Views:
    389
    ishekar
    Aug 7, 2003
  2. mark waite

    CComBSTR to STL string

    mark waite, Nov 19, 2003, in forum: C++
    Replies:
    1
    Views:
    566
    Mike Wahler
    Nov 19, 2003
  3. Xav

    std::endl type unknown

    Xav, Dec 12, 2003, in forum: C++
    Replies:
    2
    Views:
    2,968
    Alf P. Steinbach
    Dec 12, 2003
  4. Filipe Sousa
    Replies:
    12
    Views:
    781
  5. Kenneth McDonald

    Why stack overflow with such a small stack?

    Kenneth McDonald, Aug 30, 2007, in forum: Ruby
    Replies:
    7
    Views:
    262
    Kenneth McDonald
    Sep 1, 2007
Loading...

Share This Page