std::map clear throws an exception

  • Follow


Hi ,

    When I am trying to using map::clear to clear my map , I am getting
an exception .

     map<long, CMyClass> myMap;

     myMap.clear() ;     // Clear the map before doing anything new .

     Any help would be appreciated .

     Thanks .

Sujay


      [ See http://www.gotw.ca/resources/clcm.htm for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]
0
Reply ghosh.sujay (1) 2/26/2005 12:56:31 PM

ghosh.sujay@gmail.com writes:

> Hi ,
>
>     When I am trying to using map::clear to clear my map , I am getting
> an exception .
>
>      map<long, CMyClass> myMap;
>
>      myMap.clear() ;     // Clear the map before doing anything new .
>
>      Any help would be appreciated .

Some possible explanations:

1. The destructor of CMyClass is throwing (that's a no-no).

2. Your code has a bug somewhere, you have previously corrupted your
   program state, and you're working on an OS like Windows, where
   symptoms of coding errors like segfaults are turned into something
   that can be mistaken for a C++ exception.

IMO, your best bet is careful tracing with a good debugger.

Good luck!
-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com

      [ See http://www.gotw.ca/resources/clcm.htm for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]
0
Reply David 2/26/2005 3:23:42 PM


1 Replies
719 Views

(page loaded in 0.067 seconds)

Similiar Articles:













7/23/2012 9:30:09 AM


Reply: