Lodestone.Common
Loading...
Searching...
No Matches
Casts.h
Go to the documentation of this file.
1
8#ifndef LODESTONE_CASTS_H
9#define LODESTONE_CASTS_H
10#include <memory>
11
13 class Casts {
14 public:
15 template <typename To, typename From>
16 static std::unique_ptr<To> static_unique_pointer_cast(std::unique_ptr<From> ptr) {
17 To *p = static_cast<To *>(ptr.release());
18
19 return std::unique_ptr<To>(p);
20 }
21
22 template <typename To, typename From>
23 static std::unique_ptr<To> dynamic_unique_pointer_cast(std::unique_ptr<From> ptr) {
24 To *p = dynamic_cast<To *>(ptr.release());
25
26 return std::unique_ptr<To>(p);
27 }
28 };
29}
30
31#endif // LODESTONE_CASTS_H
Definition Casts.h:13
static std::unique_ptr< To > dynamic_unique_pointer_cast(std::unique_ptr< From > ptr)
Definition Casts.h:23
static std::unique_ptr< To > static_unique_pointer_cast(std::unique_ptr< From > ptr)
Definition Casts.h:16
Definition Casts.cpp:10