mirror of
https://github.com/borgesdan/xn65
synced 2024-12-29 21:54:47 +01:00
16 lines
467 B
C++
16 lines
467 B
C++
#ifndef MISC_HPP
|
|
#define MISC_HPP
|
|
|
|
#include <memory>
|
|
#include <utility>
|
|
|
|
namespace misc {
|
|
//Realiza um std::make_shared<TDERIVED> e converte para classe base com reinterpret_pointer_cast<TBASE>
|
|
template <typename TBASE, typename TDERIVED, class... _Types>
|
|
std::shared_ptr<TBASE> reinterpret_make_shared(_Types&&... _Args) {
|
|
auto derived = std::make_shared<TDERIVED>(std::forward<_Types>(_Args)...);
|
|
return reinterpret_pointer_cast<TBASE>(derived);
|
|
}
|
|
}
|
|
|
|
#endif |