Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Whats wrong with my emplace_back code  (Read 1406 times)

0 Members and 1 Guest are viewing this topic.

baduo

  • Newbie
  • *
  • Posts: 1
    • View Profile
    • Email
Whats wrong with my emplace_back code
« on: April 12, 2016, 01:21:01 pm »
I just started coding with c++ sfml, i'm currently working on a game which I need to create 44 green rectangles and draw them on the screen, here is my code to create them: But when I run it, it says 'std::vector<_Ty>::emplace_back' : function does not take 2 arguments, how can I fix this or am I doing it completely wrong, any help please?


struct Brick {
    RectangleShape shape;

    Brick (float mX, float mY) {
        shape.setPosition(mX,mY);
        shape.setSize(Vector2f(60,20));
        shape.setFillColor(Color::Green);
        shape.setOrigin(60 / 2, 20 / 2);
    }
};

int countBlocksX = 11;
int countBlocksY = 4;

vector<Brick> bricks;

for (int iX = 0; iX < countBlocksX; iX++) {
    for (int iY = 0; iY < countBlocksY; iY++) {
        bricks.emplace_back ((iX + 1) * (60 + 3) , (iY + 2) * (20 +3));                
    }
}

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Whats wrong with my emplace_back code
« Reply #1 on: April 12, 2016, 01:34:23 pm »
Nothing's wrong. If you use VC 10 it is a known bug, otherwise it should work fine.
Laurent Gomila - SFML developer