In class A I have:
class A{
A(){};
std::vector<sf::Vertex[2]> lines{ 5 };
};
And I somehow need to access sf::Vertex 0 and 1 of all the line objects in std::vector. The SFML documentation states on lines:
sf::Vertex line[] =
{
sf::Vertex(sf::Vector2f(10, 10)),
sf::Vertex(sf::Vector2f(150, 150))
};
I tried many things, but syntax just doesn't work out, from this:
std::vector lines{ {Vertex(100,100),Vertex( 300,300)},... }; to this:
A(){
lines[0]->sf::Vertex[0] = (100,100);
...};
But it just doesn't work out. What's the proper syntax?
An array is not a valid element type for a vector (or any other standard Container). It doesn't satisfy the requirement of being Erasable. You can instead use a class that has the array as a member. The standard library has a template for such array wrapper: std::vector<std::array<sf::Vertex, 2>>
.