mirror of
https://github.com/EQEmu/Server.git
synced 2026-01-01 08:41:29 +00:00
Removed make_unique from namegen, was conflicting with real make_unique on windows and we're set to cxx11 still
This commit is contained in:
parent
d4ea9bbee0
commit
6d3848b2c7
@ -125,20 +125,6 @@ const std::unordered_map<std::string, const std::vector<std::string>>& Generator
|
||||
return *symbols;
|
||||
}
|
||||
|
||||
|
||||
#ifdef HAVE_CXX14
|
||||
using std::make_unique;
|
||||
#else
|
||||
// make_unique is not available in c++11, so we use this template function
|
||||
// to maintain full c++11 compatibility; std::make_unique is part of C++14.
|
||||
template<typename T, typename... Args>
|
||||
std::unique_ptr<T> make_unique(Args&&... args)
|
||||
{
|
||||
return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Generator::Generator()
|
||||
{
|
||||
}
|
||||
@ -353,17 +339,17 @@ Generator::Generator(const std::string &pattern, bool collapse_triples) {
|
||||
std::unique_ptr<Generator> last;
|
||||
|
||||
std::stack<std::unique_ptr<Group>> stack;
|
||||
std::unique_ptr<Group> top = make_unique<GroupSymbol>();
|
||||
std::unique_ptr<Group> top = std::unique_ptr<GroupSymbol>();
|
||||
|
||||
for (auto c : pattern) {
|
||||
switch (c) {
|
||||
case '<':
|
||||
stack.push(std::move(top));
|
||||
top = make_unique<GroupSymbol>();
|
||||
top = std::unique_ptr<GroupSymbol>();
|
||||
break;
|
||||
case '(':
|
||||
stack.push(std::move(top));
|
||||
top = make_unique<GroupLiteral>();
|
||||
top = std::unique_ptr<GroupLiteral>();
|
||||
break;
|
||||
case '>':
|
||||
case ')':
|
||||
@ -408,7 +394,7 @@ Generator::Generator(const std::string &pattern, bool collapse_triples) {
|
||||
|
||||
std::unique_ptr<Generator> g = top->produce();
|
||||
if (collapse_triples) {
|
||||
g = make_unique<Collapser>(std::move(g));
|
||||
g = std::unique_ptr<Collapser>(new Collapser(std::move(g)));
|
||||
}
|
||||
add(std::move(g));
|
||||
}
|
||||
@ -424,16 +410,16 @@ void Generator::Group::add(std::unique_ptr<Generator>&& g)
|
||||
while (!wrappers.empty()) {
|
||||
switch (wrappers.top()) {
|
||||
case reverser:
|
||||
g = make_unique<Reverser>(std::move(g));
|
||||
g = std::unique_ptr<Reverser>(new Reverser(std::move(g)));
|
||||
break;
|
||||
case capitalizer:
|
||||
g = make_unique<Capitalizer>(std::move(g));
|
||||
g = std::unique_ptr<Capitalizer>(new Capitalizer(std::move(g)));
|
||||
break;
|
||||
}
|
||||
wrappers.pop();
|
||||
}
|
||||
if (set.size() == 0) {
|
||||
set.push_back(make_unique<Sequence>());
|
||||
set.push_back(std::unique_ptr<Sequence>());
|
||||
}
|
||||
set.back()->add(std::move(g));
|
||||
}
|
||||
@ -441,8 +427,8 @@ void Generator::Group::add(std::unique_ptr<Generator>&& g)
|
||||
void Generator::Group::add(char c)
|
||||
{
|
||||
std::string value(1, c);
|
||||
std::unique_ptr<Generator> g = make_unique<Random>();
|
||||
g->add(make_unique<Literal>(value));
|
||||
std::unique_ptr<Generator> g = std::unique_ptr<Random>();
|
||||
g->add(std::unique_ptr<Literal>(new Literal(value)));
|
||||
Group::add(std::move(g));
|
||||
}
|
||||
|
||||
@ -450,20 +436,20 @@ std::unique_ptr<Generator> Generator::Group::produce()
|
||||
{
|
||||
switch (set.size()) {
|
||||
case 0:
|
||||
return make_unique<Literal>("");
|
||||
return std::unique_ptr<Literal>(new Literal(""));
|
||||
case 1:
|
||||
return std::move(*set.begin());
|
||||
default:
|
||||
return make_unique<Random>(std::move(set));
|
||||
return std::unique_ptr<Random>(new Random(std::move(set)));
|
||||
}
|
||||
}
|
||||
|
||||
void Generator::Group::split()
|
||||
{
|
||||
if (set.size() == 0) {
|
||||
set.push_back(make_unique<Sequence>());
|
||||
set.push_back(std::unique_ptr<Sequence>());
|
||||
}
|
||||
set.push_back(make_unique<Sequence>());
|
||||
set.push_back(std::unique_ptr<Sequence>());
|
||||
}
|
||||
|
||||
void Generator::Group::wrap(wrappers_t type)
|
||||
@ -479,14 +465,14 @@ Generator::GroupSymbol::GroupSymbol() :
|
||||
void Generator::GroupSymbol::add(char c)
|
||||
{
|
||||
std::string value(1, c);
|
||||
std::unique_ptr<Generator> g = make_unique<Random>();
|
||||
std::unique_ptr<Generator> g = std::unique_ptr<Random>();
|
||||
try {
|
||||
static const auto& symbols = SymbolMap();
|
||||
for (const auto& s : symbols.at(value)) {
|
||||
g->add(make_unique<Literal>(s));
|
||||
g->add(std::unique_ptr<Literal>(new Literal(s)));
|
||||
}
|
||||
} catch (const std::out_of_range&) {
|
||||
g->add(make_unique<Literal>(value));
|
||||
g->add(std::unique_ptr<Literal>(new Literal(value)));
|
||||
}
|
||||
Group::add(std::move(g));
|
||||
}
|
||||
@ -533,4 +519,4 @@ std::string tostring(const std::wstring & s)
|
||||
}
|
||||
|
||||
return std::string(buf.data(), wn);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user