Add shared_ptr and unique_ptr alias

This commit is contained in:
scorpioblood 2024-05-21 22:42:24 +02:00
parent 367798d188
commit fd14a695bd
2 changed files with 61 additions and 7 deletions

View File

@ -38,3 +38,24 @@
#error The target system must be defined. (See https://github.com/scorpioblood/PhanesEngine for more information) #error The target system must be defined. (See https://github.com/scorpioblood/PhanesEngine for more information)
#endif // P_WIN_BUILD #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()
{
}

View File

@ -47,6 +47,12 @@
namespace Phanes::Core::Math
{
// Typenames with RealType constrain have to be floating point numbers. // Typenames with RealType constrain have to be floating point numbers.
template<typename T> template<typename T>
concept RealType = std::is_floating_point_v<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. // Typenames with IntType constrain have to be integer number.
template<typename T> template<typename T>
concept IntType = std::is_integral_v<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)...);
}
}