Well I initialize everything in a constructor including vector sizes being set to 1, to prevent undefined behavior. So the first time I add a texture then the Image vector data position 0 is empty so I just load the image. The second time I call it I need to expand and then load and bind textures..
Maybe code would be more clear than words subject to interpretation:
void TextureManager::AddTexture(std::string FileName){
if(Birthing)
Birthing = false;
else
Expand();
int x = NumberOfTextures-1;
Textures[x].LoadFromFile(FileName);
glGenTextures(1, &TextureID[x]);
glBindTexture(GL_TEXTURE_2D, TextureID[x]);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, Textures[x].GetWidth(), Textures[x].GetHeight(),
0, GL_RGBA, GL_UNSIGNED_BYTE, Textures[x].GetPixelsPtr());
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
}
If you're using an std::vector, and iterating over it with a for loop like
for(unsigned int i = 0; i < myVector.size(); i++)
//...code...
Having an empty vector will not cause any problems. It won't run any of the code inside the for loop.
Then, when you want to add a new texture, in your AddTexture function you .push_back() a new element into the vector and set it up
Right.
If you don't define any of the Big Five (copy constructor, move constructor, copy assignment operator, move assignment operator, destructor), newer compilers can even generate them implicitly. Also, by using = default or = delete, you can specify exactly which functions you want to have, without writing the implementation. A default-generated move constructor moves the member variables element-wise, which is not always what you want.
The user still has to take care to allow move semantics. For example, here the compiler must perform a copy
sf::Texture texture;
texture.loadFromFile(...);
std::vector<sf::Texture> textures;
textures.push_back(texture);
// better:
textures.push_back(std::move(texture));
In other cases, move semantics happen automatically:
sf::Texture createTexture()
{
sf::Texture texture;
texture.loadFromFile(...);
return texture;
}