Skip to content

Commit 1980ecb

Browse files
committed
Replace std::unique_ptr with xr_unique_ptr
1 parent bb5e0eb commit 1980ecb

File tree

14 files changed

+49
-22
lines changed

14 files changed

+49
-22
lines changed

src/Common/Common.vcxproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@
180180
<ClInclude Include="..\xrCommon\xr_list.h" />
181181
<ClInclude Include="..\xrCommon\xr_map.h" />
182182
<ClInclude Include="..\xrCommon\xr_set.h" />
183+
<ClInclude Include="..\xrCommon\xr_smart_pointers.h" />
183184
<ClInclude Include="..\xrCommon\xr_stack.h" />
184185
<ClInclude Include="..\xrCommon\xr_string.h" />
185186
<ClInclude Include="..\xrCommon\xr_unordered_map.h" />

src/Common/Common.vcxproj.filters

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@
8585
<ClInclude Include="..\xrCommon\xr_array.h">
8686
<Filter>xrCommon</Filter>
8787
</ClInclude>
88+
<ClInclude Include="..\xrCommon\xr_smart_pointers.h">
89+
<Filter>xrCommon</Filter>
90+
</ClInclude>
8891
</ItemGroup>
8992
<ItemGroup>
9093
<Filter Include="NvMender2003">

src/editors/ECore/stdafx.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ typedef TMsgDlgBtn TMsgDlgButtons[mbHelp];
108108
#include "xrCore/xr_token.h"
109109
#include "xrCommon/xr_vector.h"
110110
#include "xrCommon/xr_string.h"
111+
#include "xrCommon/xr_smart_pointers.h"
111112
#include "xrCore/Animation/Bone.hpp"
112113
#include "xrCore/Animation/Motion.hpp"
113114

src/xrCommon/xr_smart_pointers.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#pragma once
2+
3+
#include <memory>
4+
5+
template <typename T>
6+
using xr_unique_ptr = std::unique_ptr<T>;
7+
8+
template <typename T>
9+
using xr_shared_ptr = std::shared_ptr<T>;
10+
11+
template <class T, class... Args>
12+
inline xr_unique_ptr<T> xr_make_unique(Args&&... args)
13+
{
14+
return std::make_unique<T>(args...);
15+
}
16+
17+
template <class T, class... Args>
18+
inline xr_shared_ptr<T> xr_make_shared(Args&&... args)
19+
{
20+
return std::make_shared<T>(args...);
21+
}

src/xrCore/FileSystem.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include "vfw.h"
1212
#endif
1313

14-
std::unique_ptr<EFS_Utils> xr_EFS;
14+
xr_unique_ptr<EFS_Utils> xr_EFS;
1515
//----------------------------------------------------
1616
EFS_Utils::EFS_Utils() {}
1717
EFS_Utils::~EFS_Utils() {}

src/xrCore/FileSystem.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class XRCORE_API EFS_Utils
4242
static xr_string ExtractFileExt(LPCSTR src);
4343
static xr_string ExcludeBasePath(LPCSTR full_path, LPCSTR excl_path);
4444
};
45-
extern XRCORE_API std::unique_ptr<EFS_Utils> xr_EFS;
45+
extern XRCORE_API xr_unique_ptr<EFS_Utils> xr_EFS;
4646
#define EFS (*xr_EFS)
4747

4848
#endif /*_INCDEF_FileSystem_H_*/

src/xrCore/LocatorAPI.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
const u32 BIG_FILE_READER_WINDOW_SIZE = 1024 * 1024;
2828

29-
std::unique_ptr<CLocatorAPI> xr_FS;
29+
xr_unique_ptr<CLocatorAPI> xr_FS;
3030

3131
#ifdef _EDITOR
3232
static constexpr pcstr FSLTX = "fs.ltx"

src/xrCore/LocatorAPI.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "LocatorAPI_defs.h"
1111
//#include "xrCore/Threading/Lock.hpp"
1212
#include "xrCommon/xr_map.h"
13+
#include "xrCommon/xr_smart_pointers.h"
1314
#include "xrCommon/predicates.h"
1415
#include "Common/Noncopyable.hpp"
1516

@@ -255,5 +256,5 @@ class XRCORE_API CLocatorAPI : Noncopyable
255256
void unlock_rescan();
256257
};
257258

258-
extern XRCORE_API std::unique_ptr<CLocatorAPI> xr_FS;
259+
extern XRCORE_API xr_unique_ptr<CLocatorAPI> xr_FS;
259260
#define FS (*xr_FS)

src/xrCore/ModuleLookup.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#pragma once
2-
#include <memory>
2+
#include "xrCommon/xr_smart_pointers.h"
33

44
namespace XRay
55
{
@@ -23,15 +23,15 @@ class XRCORE_API ModuleHandle
2323
void* GetProcAddress(pcstr procName) const;
2424
};
2525

26-
using Module = std::unique_ptr<ModuleHandle>;
26+
using Module = xr_unique_ptr<ModuleHandle>;
2727

2828
inline auto LoadModule(bool dontUnload = false)
2929
{
30-
return std::make_unique<ModuleHandle>(dontUnload);
30+
return xr_make_unique<ModuleHandle>(dontUnload);
3131
}
3232

3333
inline auto LoadModule(pcstr moduleName, bool dontUnload = false)
3434
{
35-
return std::make_unique<ModuleHandle>(moduleName, dontUnload);
35+
return xr_make_unique<ModuleHandle>(moduleName, dontUnload);
3636
}
3737
}

src/xrCore/Threading/ThreadPool.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include <mutex>
1616
#include <condition_variable>
1717
#include <functional>
18-
#include <memory>
18+
#include "xrCommon/xr_smart_pointers.h"
1919

2020
class XRCORE_API Thread
2121
{
@@ -42,7 +42,7 @@ class XRCORE_API Thread
4242
class ThreadPool
4343
{
4444
public:
45-
xr_vector<std::unique_ptr<Thread>> threads;
45+
xr_vector<xr_unique_ptr<Thread>> threads;
4646

4747
void initialize()
4848
{

0 commit comments

Comments
 (0)