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

  • Home
  • SEARCH
  • 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 927019
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T19:47:01+00:00 2026-05-15T19:47:01+00:00

I have the following code (which largely follows the first example here: http://www.boost.org/doc/libs/1_42_0/libs/multi_index/doc/examples.html )).

  • 0

I have the following code (which largely follows the first example here: http://www.boost.org/doc/libs/1_42_0/libs/multi_index/doc/examples.html)). For some reason, with only 10000 insertations to the multi-index, it takes several minutes to run the program. Am I doing something wrong or is this expected?

struct A  
{  
  int id;  
  int name;  
  int age;  
  A(int id_,int name_,int age_):id(id_),name(name_),age(age_){}  
};  


/* tags for accessing the corresponding indices*/  
struct id{};  
struct name{};  
struct age{};  

typedef multi_index_container<  
  A,  
  indexed_by<  
    ordered_unique<  
      tag<id>,  BOOST_MULTI_INDEX_MEMBER(A,int,id)>,  
    ordered_non_unique<  
      tag<name>,BOOST_MULTI_INDEX_MEMBER(A,int,name)>,  
    ordered_non_unique<  
      tag<age>, BOOST_MULTI_INDEX_MEMBER(A,int,age)> >  
> A_set;  



int main()  
{  
  A_set es;  

  for (int a = 0; a != 10000; a++) {  
    es.insert(A(a,a+1,a+2));  
  }  
  return 0; 
}
  • 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-15T19:47:02+00:00Added an answer on May 15, 2026 at 7:47 pm

    Are you by any chance compiling in debug mode? It finishes near instantly with the default release configuration in Visual Studio 2008. If you’re compiling in debug mode and you almost followed the example to the letter, including the pre-processor stuff and still had this part:

    #ifndef NDEBUG
    #define BOOST_MULTI_INDEX_ENABLE_INVARIANT_CHECKING
    #define BOOST_MULTI_INDEX_ENABLE_SAFE_MODE
    #endif
    

    Then removing/disabling these defines will also significantly speed up execution time. (By at least 180x on my machine, didn’t bother letting it finish.) What the consequences of disabling or removing these things in a debug build is, I don’t know.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code which I call google #!/bin/bash q=$1 open http://www.google.com/search?q=$q It
I have the following (here simplified) code which I want to test with FakeItEasy
I have following code which works for radio buttons but need to be changed
I want to know is below code correct ? I have following code which
I have the following code which should put programs startable in Bash. if [
I have the following code which reads in the follow file, append a \r\n
I have the following code which re-uses a CookieContainer which logs in on the
I have the following code which I stripped out of any non-essential lines to
I have the following code which ends up forever reading '/proc/cpuinfo' as it keeps
I have the following code which lets the user plot two points on a

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.