mirror of
https://github.com/wiiu-env/libwupsbackend.git
synced 2024-11-25 11:16:52 +01:00
17 lines
666 B
C++
17 lines
666 B
C++
#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>
|
|
inline typename std::unique_ptr<T> make_unique_nothrow(size_t num) noexcept {
|
|
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)...));
|
|
} |