Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5951603
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:33:40+00:00 2026-05-22T17:33:40+00:00

I am getting strange behavior from within the boost::unordered_map library (v1.45.0). In my class

  • 0

I am getting strange behavior from within the boost::unordered_map library (v1.45.0).

In my class I create an object:

boost::unordered_map<uint16, MyStruct *> bufferStructMap;

Then I initialize it in the constructor initialization list:

 MyClass::MyClass () : bufferStructMap( ) { .... } 

Then I try to pull something out of it using the method “at” (see API in link):

const uint16 bufferNumber = 1;
try {

    MyStruct * ptr = ( this->bufferStructMap.at( bufferNumber ) );
}
catch ( std::out_of_range & e ){

  //deal with exception
}

When the map is empty, the application aborts with the call to “bufferStructMap.at( … )”, even though the API says the only exception that can be thrown is a std::out_of_range.

Can anyone detect a problem with my code, or is this a boost bug?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T17:33:40+00:00Added an answer on May 22, 2026 at 5:33 pm

    Mark B is probably right. If not, it looks like a bug in Boost.

    Although… Since std::tr1::unordered_map (and the C++0x version? not sure) does not provide at(), you might want to just use find().

    // Save typing, allow easy change to std::unordered_map someday
    typedef boost::unordered_map<uint16, MyStruct *> map_t;
    
    map_t bufferStructMap;
    

    …

    map_t::const_iterator p = bufferStructMap.find(bufferNumber);
    if (p == bufferStructMap.end())
        // not found
    else
        // p->second is your value
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm getting so very strange behavior in my Objective C library (for iPhone). What
I am getting some strange behavior from list view. I need to change background
I'm getting some strange behaviour from EF Code First when I add an object
I'm getting some strange behavior from a listview/the getChildAt method. I have a HashSet,
I am getting strange behavior from MSBuild. I use the command: msbuild.exe /p:Configuration="Release|Windows Mobile
Right now I'm getting this strange behavior from IE where it's not showing my
http://jsfiddle.net/s6Umb/ I'm getting this strange behavior where when I create a datepicker, there appears
Hi I'm getting strange feedback from the feedback sandbox server. Actually there should be
I'm getting strange error 'int' object has no attribute 'startswith' I haven't used the
I'm getting a very strange behavior in MySQL, which looks like some kind of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.