Ref. Scope
- Added Ref<T> and Scope<T> types to replace the std::shared_ptr<T> and std::unique_ptr<T>, currently it is being used as an alias
This commit is contained in:
parent
8287b89fad
commit
0360d094d2
1 changed files with 37 additions and 0 deletions
|
@ -31,6 +31,7 @@
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// operations
|
// operations
|
||||||
#define BIT(x) 1 << x
|
#define BIT(x) 1 << x
|
||||||
|
|
||||||
|
@ -43,6 +44,42 @@
|
||||||
#define LT_CLIENT_ASSERT(x, ...) { if(!(x)) { LT_CLIENT_CRITICAL(__VA_ARGS__); LT_BREAK(); throw ::Light::FailedClientAssertion(__FILE__, __LINE__); } }
|
#define LT_CLIENT_ASSERT(x, ...) { if(!(x)) { LT_CLIENT_CRITICAL(__VA_ARGS__); LT_BREAK(); throw ::Light::FailedClientAssertion(__FILE__, __LINE__); } }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
namespace Light {
|
||||||
|
|
||||||
|
// Ref (std::shared_ptr)
|
||||||
|
template<typename T>
|
||||||
|
using Ref = std::shared_ptr<T>;
|
||||||
|
|
||||||
|
template<typename T, typename... Args>
|
||||||
|
constexpr std::shared_ptr<T> CreateRef(Args... args)
|
||||||
|
{
|
||||||
|
return std::make_shared<T>(std::forward<Args>(args)...);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
constexpr std::shared_ptr<T> MakeRef(T* rawPointer)
|
||||||
|
{
|
||||||
|
return std::shared_ptr<T>(T);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Scope (std::unique_ptr)
|
||||||
|
template<typename T>
|
||||||
|
using Scope = std::unique_ptr<T>;
|
||||||
|
|
||||||
|
template<typename T, typename... Args>
|
||||||
|
constexpr std::unique_ptr<T> CreateScope(Args... args)
|
||||||
|
{
|
||||||
|
return std::make_unique<T>(std::forward<Args>(args)...);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
constexpr std::unique_ptr<T> MakeScope(T* rawPointer)
|
||||||
|
{
|
||||||
|
return std::unique_ptr<T>(rawPointer);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
///*** [ PORTABLES ] ***///
|
///*** [ PORTABLES ] ***///
|
||||||
//** PORTABLE_DEBUG_BREAK **//
|
//** PORTABLE_DEBUG_BREAK **//
|
||||||
// copied from: https://github.com/nemequ/portable-snippets/tree/master/debug-trap
|
// copied from: https://github.com/nemequ/portable-snippets/tree/master/debug-trap
|
||||||
|
|
Loading…
Add table
Reference in a new issue