Skip to content

Commit 6ff3e64

Browse files
committed
Add make_unique for C++11
1 parent 1da3377 commit 6ff3e64

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

llama.cpp

+12-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,17 @@
1515
// TODO: move somewhere else
1616
#define QK 32
1717

18+
// Define std::make_unique if it's not available
19+
// (e.g. on C++11)
20+
#ifndef __cpp_lib_make_unique
21+
template<typename T, typename... Args>
22+
std::unique_ptr<T> make_unique(Args&&... args) {
23+
return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
24+
}
25+
#else
26+
using std::make_unique;
27+
#endif
28+
1829
// determine number of model parts based on the dimension
1930
static const std::map<int, int> LLAMA_N_PARTS = {
2031
{ 4096, 1 },
@@ -106,7 +117,7 @@ struct llama_context
106117
model(std::move(model)),
107118
vocab(std::move(vocab)),
108119
params(params),
109-
state(std::make_unique<llama_state>())
120+
state(make_unique<llama_state>())
110121
{
111122
}
112123
~llama_context(){

0 commit comments

Comments
 (0)