[ox/std] Add proper forward function
This commit is contained in:
parent
78d444c2e5
commit
7ea0654af6
2
deps/ox/src/ox/std/memory.hpp
vendored
2
deps/ox/src/ox/std/memory.hpp
vendored
@ -116,7 +116,7 @@ constexpr bool operator!=(std::nullptr_t, const UniquePtr<T> &p2) noexcept {
|
||||
template<typename T, typename ...Args>
|
||||
[[nodiscard]]
|
||||
constexpr auto make_unique(Args&&... args) {
|
||||
return UniquePtr(new T(static_cast<Args&&>(args)...));
|
||||
return UniquePtr(new T(forward<Args>(args)...));
|
||||
}
|
||||
|
||||
}
|
||||
|
3
deps/ox/src/ox/std/typetraits.hpp
vendored
3
deps/ox/src/ox/std/typetraits.hpp
vendored
@ -175,4 +175,7 @@ struct remove_reference<T&&> {
|
||||
using type = T;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
using remove_reference_t = typename remove_reference<T>::type;
|
||||
|
||||
}
|
||||
|
19
deps/ox/src/ox/std/utility.hpp
vendored
19
deps/ox/src/ox/std/utility.hpp
vendored
@ -12,9 +12,28 @@
|
||||
|
||||
namespace ox {
|
||||
|
||||
template<class T>
|
||||
constexpr T &&forward(remove_reference_t<T> &t) noexcept {
|
||||
return static_cast<T&&>(t);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
constexpr T &&forward(remove_reference_t<T> &&t) noexcept {
|
||||
return static_cast<T&&>(t);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
constexpr typename remove_reference<T>::type &&move(T &&t) noexcept {
|
||||
return static_cast<typename remove_reference<T>::type&&>(t);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#if !__has_include(<utility>)
|
||||
namespace std {
|
||||
template<typename T>
|
||||
constexpr typename ox::remove_reference<T>::type &&move(T &&t) noexcept {
|
||||
return static_cast<typename ox::remove_reference<T>::type&&>(t);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
3
deps/ox/src/ox/std/vector.hpp
vendored
3
deps/ox/src/ox/std/vector.hpp
vendored
@ -67,6 +67,7 @@ struct SmallVector<T, 0> {
|
||||
*items = bit_cast<T*>(new AllocAlias<T>[cap]);
|
||||
}
|
||||
|
||||
[[maybe_unused]]
|
||||
constexpr void moveItemsFrom(T**, SmallVector&, const std::size_t, const std::size_t) noexcept {
|
||||
}
|
||||
|
||||
@ -488,7 +489,7 @@ void Vector<T, SmallVectorSize>::emplace_back(Args&&... args) {
|
||||
if (m_size == m_cap) {
|
||||
expandCap(m_cap ? m_cap * 2 : 100);
|
||||
}
|
||||
new (&m_items[m_size]) T{static_cast<Args>(args)...};
|
||||
new (&m_items[m_size]) T{forward<Args>(args)...};
|
||||
++m_size;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user