Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. ATL / WTL / STL
  4. std::map and error checking

std::map and error checking

Scheduled Pinned Locked Moved ATL / WTL / STL
c++csharpvisual-studiohelpquestion
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    bkelly13
    wrote on last edited by
    #1

    Windows 7, Visual Studio 2008, MFC, C++, Dialog My application makes use of an std::map, inserting records with the following:

    m_tmats_definition_map[ the_key ] = m_one_definition_record;

    the_key is a CString and m_one_definition_record is a structure of several CStrings and a few various fields such as integers. That seems to be working. Now in the event something does not work out right I want some error checking. I am not finding much of anything concerning run time checking on this insert operation. Probably not looking in the right places or using the right search phrase. Where can I look to find a good discussion on this topic?

    Thanks for your time If you work with telemetry, please check this bulletin board: http://www.bkelly.ws/irig\_106/

    G L M 3 Replies Last reply
    0
    • B bkelly13

      Windows 7, Visual Studio 2008, MFC, C++, Dialog My application makes use of an std::map, inserting records with the following:

      m_tmats_definition_map[ the_key ] = m_one_definition_record;

      the_key is a CString and m_one_definition_record is a structure of several CStrings and a few various fields such as integers. That seems to be working. Now in the event something does not work out right I want some error checking. I am not finding much of anything concerning run time checking on this insert operation. Probably not looking in the right places or using the right search phrase. Where can I look to find a good discussion on this topic?

      Thanks for your time If you work with telemetry, please check this bulletin board: http://www.bkelly.ws/irig\_106/

      G Offline
      G Offline
      Garth J Lancaster
      wrote on last edited by
      #2

      ouch - hard question - I just had a look and its a right PITA - 'Dinkumware' and SGI used to have good manuals (and even finding what exceptions are thrown within is hard enough) SGI's manual page for MAP is ... http://www.sgi.com/tech/stl/Map.html[^] that may give you a start point - what sort of error's do you expect ? dont forget that map doesnt throw an error for a duplicate key value (the commonest issue I guess) - it simply replaces the existing value... for that reason, you should use find() first on the map to see if the value already exists 'g'

      B 1 Reply Last reply
      0
      • G Garth J Lancaster

        ouch - hard question - I just had a look and its a right PITA - 'Dinkumware' and SGI used to have good manuals (and even finding what exceptions are thrown within is hard enough) SGI's manual page for MAP is ... http://www.sgi.com/tech/stl/Map.html[^] that may give you a start point - what sort of error's do you expect ? dont forget that map doesnt throw an error for a duplicate key value (the commonest issue I guess) - it simply replaces the existing value... for that reason, you should use find() first on the map to see if the value already exists 'g'

        B Offline
        B Offline
        bkelly13
        wrote on last edited by
        #3

        I don't know what sort of errors to expect. Isn't that one of the joys of software? Good link. Good point with the Find(). I do want to know if there are duplicates and will incorporate that.

        Thanks for your time If you work with telemetry, please check this bulletin board: http://www.bkelly.ws/irig\_106/

        1 Reply Last reply
        0
        • B bkelly13

          Windows 7, Visual Studio 2008, MFC, C++, Dialog My application makes use of an std::map, inserting records with the following:

          m_tmats_definition_map[ the_key ] = m_one_definition_record;

          the_key is a CString and m_one_definition_record is a structure of several CStrings and a few various fields such as integers. That seems to be working. Now in the event something does not work out right I want some error checking. I am not finding much of anything concerning run time checking on this insert operation. Probably not looking in the right places or using the right search phrase. Where can I look to find a good discussion on this topic?

          Thanks for your time If you work with telemetry, please check this bulletin board: http://www.bkelly.ws/irig\_106/

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          You need to check return values of function calls that provide information. See here[^] for the insert function.

          Use the best guess

          1 Reply Last reply
          0
          • B bkelly13

            Windows 7, Visual Studio 2008, MFC, C++, Dialog My application makes use of an std::map, inserting records with the following:

            m_tmats_definition_map[ the_key ] = m_one_definition_record;

            the_key is a CString and m_one_definition_record is a structure of several CStrings and a few various fields such as integers. That seems to be working. Now in the event something does not work out right I want some error checking. I am not finding much of anything concerning run time checking on this insert operation. Probably not looking in the right places or using the right search phrase. Where can I look to find a good discussion on this topic?

            Thanks for your time If you work with telemetry, please check this bulletin board: http://www.bkelly.ws/irig\_106/

            M Offline
            M Offline
            MicroVirus
            wrote on last edited by
            #5

            In this case, there's nothing you need to do. If something goes wrong, it'll throw a C++ exception. Most likely causes will be that a new element can't be constructed, or that there is insufficient memory. But maybe this is not what you meant. You say you want error checking; why do you want error checking? What is that you want to accomplish? Perhaps the solution is different.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups