Q: What is the correct way to emplace_back an object into a vector using the range-based for loop? C++ I have an object that I want to add it to the vector container, but I would like to know is that 2 ways I did the same thing? And what is the correct way to do it? 
The reason why I did m_boid.emplace_back(std::move(bird)); is because bird is a range-based-for-loop variable and if I don't use bird it will prompt me a warning saying Unsed variable bird But program is still able to run as it's not an error.
What is the correct way to emplace_back an object into a vector using the range-based for loop? 
Thank you in advance.
Boid::Boid(int size)
{
    m_boid.resize(size);  //vector of unique pointer

    for(auto &bird : m_boid)
    {
        //Create an object
        m_obj.reset(new Boid); //unique pointer

            // Add object to vector. Is this 2 below the same thing?
            m_boid.emplace_back(std::move(bird));  //Should I do this?
            m_boid.emplace_back(std::move(m_obj)); //Or should I do this?
    }
}



EDITED. HOW ABOUT THIS? is this ok? 
void Boid::initBoid(unsigned int containSize)
{

    m_boid.resize(containSize);

    for(auto &bird : m_boid)
    {
        bird.reset(new Boid);
        bird->createVAO();
    }
}


A: 
What is the correct way to emplace_back an object into a vector using the range-based for loop?

I'd say none. emplace_back could invalidate iterators in case of a reallocation, thus you'd get an UB in that case.
