2 #include <score/tools/Debug.hpp>
7 template <
typename Derived,
typename Base,
typename Del>
8 std::unique_ptr<Derived> dynamic_unique_ptr_cast(std::unique_ptr<Base, Del>&& p)
10 if(Derived* result =
dynamic_cast<Derived*
>(p.get()))
13 return std::unique_ptr<Derived>(result);
18 template <
typename T,
typename U>
19 auto safe_unique_ptr_cast(std::unique_ptr<U> other)
21 auto res = dynamic_unique_ptr_cast<T>(other);
27 template <
typename Derived,
typename Base,
typename Del>
28 std::unique_ptr<Derived> static_unique_ptr_cast(std::unique_ptr<Base, Del>&& p)
30 return std::unique_ptr<Derived>(
static_cast<Derived*
>(p.release()));
33 #define safe_unique_ptr_cast static_unique_ptr_cast