#pragma once #include #include template std::unique_ptr make_unique_nothrow(Args &&...args) noexcept(noexcept(T(std::forward(args)...))) { return std::unique_ptr(new (std::nothrow) T(std::forward(args)...)); } template inline typename std::unique_ptr make_unique_nothrow(size_t num) noexcept { return std::unique_ptr(new (std::nothrow) std::remove_extent_t[num]()); } template std::shared_ptr make_shared_nothrow(Args &&...args) noexcept(noexcept(T(std::forward(args)...))) { return std::shared_ptr(new (std::nothrow) T(std::forward(args)...)); } template bool remove_first_if(std::vector &list, Predicate pred) { auto it = list.begin(); while (it != list.end()) { if (pred(*it)) { list.erase(it); return true; } it++; } return false; }