BAN: Fix all emplace functions to actually do perfect forwarding
This commit is contained in:
parent
99cf1c0330
commit
0d2d6e5348
|
@ -33,9 +33,9 @@ namespace BAN
|
|||
[[nodiscard]] ErrorOr<void> insert(const_iterator, const T&);
|
||||
[[nodiscard]] ErrorOr<void> insert(const_iterator, T&&);
|
||||
template<typename... Args>
|
||||
[[nodiscard]] ErrorOr<void> emplace_back(Args...);
|
||||
[[nodiscard]] ErrorOr<void> emplace_back(Args&&...);
|
||||
template<typename... Args>
|
||||
[[nodiscard]] ErrorOr<void> emplace(const_iterator, Args...);
|
||||
[[nodiscard]] ErrorOr<void> emplace(const_iterator, Args&&...);
|
||||
|
||||
void pop_back();
|
||||
void remove(const_iterator);
|
||||
|
@ -204,14 +204,14 @@ namespace BAN
|
|||
|
||||
template<typename T>
|
||||
template<typename... Args>
|
||||
ErrorOr<void> LinkedList<T>::emplace_back(Args... args)
|
||||
ErrorOr<void> LinkedList<T>::emplace_back(Args&&... args)
|
||||
{
|
||||
return emplace(end(), forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
template<typename... Args>
|
||||
ErrorOr<void> LinkedList<T>::emplace(const_iterator iter, Args... args)
|
||||
ErrorOr<void> LinkedList<T>::emplace(const_iterator iter, Args&&... args)
|
||||
{
|
||||
Node* next = iter.m_past_end ? nullptr : iter.m_current;
|
||||
Node* prev = next ? next->prev : m_last;
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace BAN
|
|||
[[nodiscard]] ErrorOr<void> push(T&&);
|
||||
[[nodiscard]] ErrorOr<void> push(const T&);
|
||||
template<typename... Args>
|
||||
[[nodiscard]] ErrorOr<void> emplace(Args...);
|
||||
[[nodiscard]] ErrorOr<void> emplace(Args&&...);
|
||||
|
||||
void pop();
|
||||
void clear();
|
||||
|
@ -120,7 +120,7 @@ namespace BAN
|
|||
|
||||
template<typename T>
|
||||
template<typename... Args>
|
||||
ErrorOr<void> Queue<T>::emplace(Args... args)
|
||||
ErrorOr<void> Queue<T>::emplace(Args&&... args)
|
||||
{
|
||||
TRY(ensure_capacity(m_size + 1));
|
||||
new (address_of(m_size)) T(forward<Args>(args)...);
|
||||
|
|
|
@ -73,9 +73,9 @@ namespace BAN
|
|||
[[nodiscard]] ErrorOr<void> push_back(T&&);
|
||||
[[nodiscard]] ErrorOr<void> push_back(const T&);
|
||||
template<typename... Args>
|
||||
[[nodiscard]] ErrorOr<void> emplace_back(Args...);
|
||||
[[nodiscard]] ErrorOr<void> emplace_back(Args&&...);
|
||||
template<typename... Args>
|
||||
[[nodiscard]] ErrorOr<void> emplace(size_type, Args...);
|
||||
[[nodiscard]] ErrorOr<void> emplace(size_type, Args&&...);
|
||||
[[nodiscard]] ErrorOr<void> insert(size_type, T&&);
|
||||
[[nodiscard]] ErrorOr<void> insert(size_type, const T&);
|
||||
|
||||
|
@ -187,7 +187,7 @@ namespace BAN
|
|||
|
||||
template<typename T>
|
||||
template<typename... Args>
|
||||
ErrorOr<void> Vector<T>::emplace_back(Args... args)
|
||||
ErrorOr<void> Vector<T>::emplace_back(Args&&... args)
|
||||
{
|
||||
TRY(ensure_capacity(m_size + 1));
|
||||
new (address_of(m_size)) T(forward<Args>(args)...);
|
||||
|
@ -197,7 +197,7 @@ namespace BAN
|
|||
|
||||
template<typename T>
|
||||
template<typename... Args>
|
||||
ErrorOr<void> Vector<T>::emplace(size_type index, Args... args)
|
||||
ErrorOr<void> Vector<T>::emplace(size_type index, Args&&... args)
|
||||
{
|
||||
ASSERT(index <= m_size);
|
||||
TRY(ensure_capacity(m_size + 1));
|
||||
|
|
Loading…
Reference in New Issue