Thread: Iterators to different containers problem

  1. #1
    Registered User
    Join Date
    Nov 2010
    Posts
    18

    Iterators to different containers problem

    Hi,

    I have been struggling with finding a solution to my program.

    I have an expression tree which contains nodes which have std::set as there data member.

    I am trying to use the set_union() function to return a union of the sets, but since the set_union() function parameters point to different containers, I get a runtime error:

    Debug assertion failed. Expression map/set iterators incompatible
    I have been Googling, and it seems other people have had similar problems, and so I come here to ask for advice on how I should go about solving the issue..

    Would really appreciate some advice on how I can overcome this issue, been stuck for a couple of days now and seem to be getting no where.

    Many thanks.
    Last edited by Orange Lozenge; 02-01-2011 at 04:01 PM.

  2. #2
    'Allo, 'Allo, Allo
    Join Date
    Apr 2008
    Posts
    639
    Your get_setnodemember returns a set by value, so everytime you call it makes a separate copy. Thus:
    nodea->get_setnodemember().begin(), // begin called on one copy of the set
    nodea->get_setnodemember().end(), // end called on a completely different, iterator incompatible copy of the set

  3. #3
    Registered User
    Join Date
    Nov 2010
    Posts
    18
    Hey thanks ever so much adey, sorted it!

    Last edited by Orange Lozenge; 02-01-2011 at 04:01 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help understanding a problem
    By dnguyen1022 in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2009, 04:21 PM
  2. Memory problem with Borland C 3.1
    By AZ1699 in forum C Programming
    Replies: 16
    Last Post: 11-16-2007, 11:22 AM
  3. Someone having same problem with Code Block?
    By ofayto in forum C++ Programming
    Replies: 1
    Last Post: 07-12-2007, 08:38 AM
  4. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  5. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06:54 PM