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 134533
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T06:37:50+00:00 2026-05-11T06:37:50+00:00

I am trying to find the set difference of two vectors, so i do

  • 0

I am trying to find the set difference of two vectors, so i do something like this:

std::vector<sha1_hash> first_vec, second_vec, difference_vec;  // populate first_vec and second_vec ...  std::sort(first_vec.begin(),first_vec.end()); std::sort(second_vec.begin(),second_vec.end());  std::set_difference(first_vec.begin(),first_vec.end(),             second_vec.begin(),second_vec.end(),             difference_vec.begin()); 

When i run this in debug, i get the following run-time assertion failure (in ‘vector’):

_SCL_SECURE_VALIDATE_RANGE(_Myptr < ((_Myvec *)(this->_Getmycont()))->_Mylast); 

I am using VS 2008. Any ideas on what can trigger this?

  • 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. 2026-05-11T06:37:51+00:00Added an answer on May 11, 2026 at 6:37 am

    Like most c++ algorithms, set_difference does not create new entries in the output vector where none existed before. You ned to create space in the output to hold the results.

    Edit: Or use an an insert iterator (following untested):

     back_insert_iterator< std::vector<sha1_hash> > bi( difference_vec );   std::set_difference(first_vec.begin(),first_vec.end(),             second_vec.begin(),second_vec.end(),             bi); 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 69k
  • Answers 69k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Try this: $ echo oneone oneone $ !!:gs/one/two/ # Repeats… May 11, 2026 at 12:38 pm
  • added an answer Wow, it's good to be in good company. I have… May 11, 2026 at 12:38 pm
  • added an answer If you have a complex project it might be worth… May 11, 2026 at 12:38 pm

Related Questions

I am trying to find the virtual file that contains the current users id.
i am trying to find the best way to display results on my page
I am trying to find the best way to design the database in order
I am trying to find the best practice for generating and outputting html which
I am creating a reverse proxy and I am trying to find the optimal
I've become very addicted to Project Euler recently and am trying to do this
I am trying to determine the best time efficient algorithm to accomplish the task
I've got a .NET 3.5 class lib that I am trying to write some
I am trying to find a generic way of accessing a set of containers.

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.