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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T18:11:02+00:00 2026-06-09T18:11:02+00:00

I have the following vector to store elements of type player: std::vector<player> players; in

  • 0

I have the following vector to store elements of type player:

std::vector<player> players;

in a class called game which has the following function:

void game::removePlayer(string name) {
  vector<player>::iterator begin = players.begin();

  // find the player
  while (begin != players.end()) {
      if (begin->getName() == name) {
          break;
      }
      ++begin;
  }

  if (begin != players.end())
      players.erase(begin);

}

I get the following error:

    1>------ Build started: Project: texas holdem, Configuration: Debug Win32 ------
1>  game.cpp
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\xutility(2514): error C2582: 'operator =' function is unavailable in 'player'
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\xutility(2535) : see reference to function template instantiation '_OutIt std::_Move<_InIt,_OutIt>(_InIt,_InIt,_OutIt,std::_Nonscalar_ptr_iterator_tag)' being compiled
1>          with
1>          [
1>              _OutIt=player *,
1>              _InIt=player *
1>          ]
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\vector(1170) : see reference to function template instantiation '_OutIt std::_Move<player*,player*>(_InIt,_InIt,_OutIt)' being compiled
1>          with
1>          [
1>              _OutIt=player *,
1>              _InIt=player *
1>          ]
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\vector(1165) : while compiling class template member function 'std::_Vector_iterator<_Myvec> std::vector<_Ty>::erase(std::_Vector_const_iterator<_Myvec>)'
1>          with
1>          [
1>              _Myvec=std::_Vector_val<player,std::allocator<player>>,
1>              _Ty=player
1>          ]
1>          c:\vcprojects\texas holdem\texas holdem\game.h(29) : see reference to class template instantiation 'std::vector<_Ty>' being compiled
1>          with
1>          [
1>              _Ty=player
1>          ]
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

removing the line

players.erase(begin);

fixes the error, why is it happening though and how can I fix it?

  • 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-06-09T18:11:03+00:00Added an answer on June 9, 2026 at 6:11 pm

    You need to overload the assignment operator Player & operator= (const Player & other) for your class Player. This required because erase requires it’s argument to be copyable (it needs to rearrange the other elements of the vector after removal).

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

Sidebar

Related Questions

I have the following function which creates a std::vector of iterators into another container:
Say I have the following template function: template <class T> void apply(const vector<complex<T> >&
I have the following: typedef std::function<void(const EventArgs&)> event_type; class Event : boost::noncopyable { private:
Say want to store the following: typedef std::function<void(int)> MyFunctionDecl; ..in a collection: typedef std::vector<MyFunctionDecl>
I have the following existing classes: class Gaussian { public: virtual Vector get_mean() =
I have the following template declaration: template <typename T> void IterTable(int& rIdx, std::vector<double>& rVarVector,
I have the following code: #include <iostream> #include <vector> using namespace std; struct A{};
I have an std::vector -like class that is compiled with Visual C++ 2008. There's
I have the following simple Graph class, where for each Node , I store
I have the following data structure (an atomic vector?) output from daply in plyr

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.