Add shared_ptr and unique_ptr alias
This commit is contained in:
parent
367798d188
commit
fd14a695bd
@ -38,3 +38,24 @@
|
||||
#error The target system must be defined. (See https://github.com/scorpioblood/PhanesEngine for more information)
|
||||
|
||||
#endif // P_WIN_BUILD
|
||||
|
||||
|
||||
namespace Phanes
|
||||
{
|
||||
|
||||
template<typename T>
|
||||
using Ref = std::shared_ptr<T>;
|
||||
|
||||
template<typename T, typename ...Args>
|
||||
constexpr Ref<T> MakeRef(Args&& ...args)
|
||||
{
|
||||
return std::make_shared<T>(std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
int test()
|
||||
{
|
||||
|
||||
}
|
@ -47,6 +47,12 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
namespace Phanes::Core::Math
|
||||
{
|
||||
|
||||
// Typenames with RealType constrain have to be floating point numbers.
|
||||
template<typename T>
|
||||
concept RealType = std::is_floating_point_v<T>;
|
||||
@ -54,3 +60,30 @@ concept RealType = std::is_floating_point_v<T>;
|
||||
// Typenames with IntType constrain have to be integer number.
|
||||
template<typename T>
|
||||
concept IntType = std::is_integral_v<T>;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Alias for shared_ptr
|
||||
template<typename T>
|
||||
using Ref = std::shared_ptr<T>;
|
||||
|
||||
// Alias for make_shared
|
||||
template<typename T, typename ...Args>
|
||||
constexpr Ref<T> MakeRef(Args&& ...args)
|
||||
{
|
||||
return std::make_shared<T>(std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
// Alias for unique ptr
|
||||
template<typename T>
|
||||
using Scope = std::unique_ptr<T>;
|
||||
|
||||
// Alias for make_unique
|
||||
template<typename T, typename ...Args>
|
||||
constexpr Scope<T> MakeScope(Args&& ...args)
|
||||
{
|
||||
return std::make_unique<T>(std::forward<Args>(args)...);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user