I was watching a youtube video on how to implement your own vector/dynamic_array in C++. I understood everything except one like of code, I'm new to c++ and trying to understand the underline data structure implementation. But I didn't see such a line of code like that one. The Code:
template<typename... Args>
T& EmplaceBack(Args&&... args) {
if (m_Size >= m_Capacity) {
ReAlloc(m_Capacity + m_Capacity / 2);
}
new(&m_Data[m_Size])T(std::forward<Args>(args)...);
return m_Data[m_Size++];
}
The line I didn't understand:
new(&m_Data[m_Size])T(std::forward<Args>(args)...);
What that line of code is really doing ?
Btw, I don't really know what std::forward
is.
Thx for any explanation. :)