2022-05-14 12:06:16 +02:00
|
|
|
#pragma once
|
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
template<class T, class... Args>
|
|
|
|
std::unique_ptr<T> make_unique_nothrow(Args &&...args) noexcept(noexcept(T(std::forward<Args>(args)...))) {
|
|
|
|
return std::unique_ptr<T>(new (std::nothrow) T(std::forward<Args>(args)...));
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename T>
|
2022-07-24 22:05:12 +02:00
|
|
|
inline typename std::unique_ptr<T> make_unique_nothrow(size_t num) noexcept {
|
2022-05-14 12:06:16 +02:00
|
|
|
return std::unique_ptr<T>(new (std::nothrow) std::remove_extent_t<T>[num]());
|
|
|
|
}
|
|
|
|
|
|
|
|
template<class T, class... Args>
|
|
|
|
std::shared_ptr<T> make_shared_nothrow(Args &&...args) noexcept(noexcept(T(std::forward<Args>(args)...))) {
|
|
|
|
return std::shared_ptr<T>(new (std::nothrow) T(std::forward<Args>(args)...));
|
|
|
|
}
|