title: error C2280: attempting to reference a deleted function (trying to call vector.erase)
body: <p>I'm new to C++. I'm developing a breakout-clone with SFML and Box2D, and I get this error when compiling. Details of the error:</p>
  
  <pre><code>c:\program files (x86)\visual studio express 2013\vc\include\xutility(2420): error C2280: 'Tile &amp;Tile::operator =(const Tile &amp;)' : attempting to reference a deleted function
  c:\users\harry\documents\visual studio 2013\projects\cpp-breakout\cpp-breakout\entities\tile.hpp(27) : compiler has generated 'Tile::operator =' here
  </code></pre>
  
  <p>The error comes when I try to erase Tile objects from a std::vector&lt; Tile> with vector.erase.</p>
  
  <pre><code>Tile.h
  
  class Tile : public Entity {
  public:
      Tile(b2World* world, float posX, float posY);
      void draw(sf::RenderWindow&amp; window);
  
      const float PTM_RATIO = 32.f;
      const int HALF_WIDTH = 32;
      const int HALF_HEIGHT = 16;
      int armor;
      bool flaggedToErase = false;
  
      b2Body* tileBody;
      sf::Sprite sprite;
  };
  
  Tile.cpp
  
  Tile::Tile(b2World* world, float posX, float posY)
  {
      // Define a body.
      b2BodyDef tileBodyDef;
      tileBodyDef.type = b2_staticBody;
      tileBodyDef.position.Set((posX + HALF_WIDTH) / PTM_RATIO, (posY + HALF_HEIGHT) / PTM_RATIO);
  
      // Use the body definition to create the actual body instance.
      tileBody = world-&gt;CreateBody(&amp;tileBodyDef);
      tileBody-&gt;SetUserData(this);
      // Define shape.
      b2PolygonShape tileShape;
      tileShape.SetAsBox(HALF_WIDTH / PTM_RATIO, HALF_HEIGHT / PTM_RATIO);
  
      // Define fixture.
      b2FixtureDef tileFixtureDef;
      tileFixtureDef.shape = &amp;tileShape;
      tileFixtureDef.density = 10.0f;
      tileFixtureDef.restitution = 0.1f;
      tileFixtureDef.friction = 0.0f;
      //tileFixtureDef.isSensor = true;
  
      bUserData* bud = new bUserData;
      bud-&gt;entityType = TILE;
      tileFixtureDef.userData = bud;
  
      // Create fixture.
      tileBody-&gt;CreateFixture(&amp;tileFixtureDef);
  }
  </code></pre>
  
  <p>I push Tiles to the vector in </p>
  
  <pre><code>Level.cpp
  
  std::vector&lt;Tile&gt; solidTiles;
  
  void Level::loadLevel(b2World* world) {
      // Loop through the map and set the tile position and sprites to the tiles.
      for(unsigned int i = 0; i &lt; map.size(); i++) {
          for(unsigned int j = 0; j &lt; map[i].size(); j++) {
              // Set sprites to the tiles in every grid cell which is not -1,-1.
              if(map[i][j].x != -1 &amp;&amp; map[i][j].y != -1) {
                  Tile tempTile(world, j * TILE_WIDTH, i * TILE_HEIGHT);
                  tempTile.sprite = tiles;
                  tempTile.sprite.setOrigin(sf::Vector2f(HALF_WIDTH, HALF_HEIGHT));
                  tempTile.sprite.setTextureRect(sf::IntRect(map[i][j].x * TILE_WIDTH, map[i][j].y * TILE_HEIGHT, TILE_WIDTH, TILE_HEIGHT));
                  tempTile.sprite.setPosition(sf::Vector2f(tempTile.tileBody-&gt;GetPosition().x * PTM_RATIO, tempTile.tileBody-&gt;GetPosition().y * PTM_RATIO));
                  solidTiles.push_back(tempTile);
              }
          }
      }
  }
  </code></pre>
  
  <p>And I try to erase the tiles in</p>
  
  <pre><code>PlayState.cpp
  
  void PlayState::removeSprites() {
      for(unsigned int i = 0; i &lt; level1.solidTiles.size(); i++) {
          if(level1.solidTiles[i].flaggedToErase == true) {
              level1.solidTiles.erase(level1.solidTiles.begin() + i);
          }
      }
  }
  </code></pre>
  
  <p>Is the problem somehow related to move constructor/assignment?</p>