mirror of
https://github.com/Fennix-Project/Kernel.git
synced 2025-05-28 15:34:33 +00:00
Add smart pointers to std
This commit is contained in:
parent
cd7267d3c3
commit
4cd4e4cdc6
@ -2,6 +2,7 @@
|
||||
#define __FENNIX_KERNEL_STD_H__
|
||||
|
||||
#include <types.h>
|
||||
#include <smartptr.hpp>
|
||||
#include <vector.hpp>
|
||||
#include <string.hpp>
|
||||
|
||||
@ -16,6 +17,77 @@ namespace std
|
||||
{
|
||||
};
|
||||
|
||||
template <class T>
|
||||
class smart_ptr
|
||||
{
|
||||
public:
|
||||
using SmartPointer<T>::SmartPointer;
|
||||
using SmartPointer<T>::operator*;
|
||||
using SmartPointer<T>::operator->;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
class auto_ptr
|
||||
{
|
||||
public:
|
||||
using AutoPointer<T>::AutoPointer;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
class unique_ptr
|
||||
{
|
||||
public:
|
||||
using UniquePointer<T>::UniquePointer;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
class weak_ptr
|
||||
{
|
||||
public:
|
||||
using WeakPointer<T>::WeakPointer;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
class shared_ptr
|
||||
{
|
||||
using SharedPointer<T>::SharedPointer;
|
||||
using SharedPointer<T>::operator*;
|
||||
using SharedPointer<T>::operator->;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct remove_reference
|
||||
{
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct remove_reference<T &>
|
||||
{
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct remove_reference<T &&>
|
||||
{
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
using remove_reference_t = typename remove_reference<T>::type;
|
||||
|
||||
template <typename T>
|
||||
T &&forward(remove_reference_t<T> &t) { return static_cast<T &&>(t); };
|
||||
|
||||
template <typename T>
|
||||
T &&forward(remove_reference_t<T> &&t) { return static_cast<T &&>(t); };
|
||||
|
||||
template <typename T, typename... Args>
|
||||
shared_ptr<T> make_shared(Args &&...args)
|
||||
{
|
||||
return SharedPointer<T>(new T(forward<Args>(args)...));
|
||||
};
|
||||
|
||||
template <class T>
|
||||
class vector : public Vector<T>
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user