The reason is from the implementation of vector. When a vector is created, it allocates a fix size of memory, for example, the initialize size of the vector is A. When you push element into the vector and size is up to A, then vector will automatically re-allocate an other continuous memory block with size 2*A, if it can't re-allocate with a size 2*A memory block at the same address, it will allocate a new memory block and copy the content in the old memory to the new one.
So in your first loop:
m_vecSprites.back().setTexture(m_vecTextures[i]);
From the link you provided, the definition of function "setTexture' is:
void Sprite::setTexture(const Texture& texture, bool resetRect)
{
// Recompute the texture area if requested, or if there was no valid texture & rect before
if (resetRect || (!m_texture && (m_textureRect == sf::IntRect())))
setTextureRect(IntRect(0, 0, texture.getSize().x, texture.getSize().y));
// Assign the new texture
m_texture = &texture;
}
And the member variable 'm_texture' is pointer type
the functon 'setTexture' gets a reference to m_vecTextures[i], but since the vector 'm_vecTextures' will still increase, if it reaches the initial size, the vector will resize and move the memory block, and the reference could become valid.
if the vector is initialize with size INTRO_LOGO_COUNT, the first loop will work fine.