2#include <score/tools/Debug.hpp>
7template <
typename Derived,
typename Base,
typename Del>
8std::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);
18template <
typename T,
typename U>
19auto safe_unique_ptr_cast(std::unique_ptr<U> other)
21 auto res = dynamic_unique_ptr_cast<T>(other);
27template <
typename Derived,
typename Base,
typename Del>
28std::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