Skip to content

Commit

Permalink
Merge pull request #3537 from ab9rf/no-more-dts
Browse files Browse the repository at this point in the history
replace `dts:make_unique` with `std::make_unique`
  • Loading branch information
myk002 authored Jul 8, 2023
2 parents ad49c67 + 1fba8b1 commit 94727a0
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 29 deletions.
6 changes: 3 additions & 3 deletions library/Core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1404,7 +1404,7 @@ Core::~Core()
}

Core::Core() :
d(dts::make_unique<Private>()),
d(std::make_unique<Private>()),
script_path_mutex{},
HotkeyMutex{},
HotkeyCond{},
Expand Down Expand Up @@ -1501,7 +1501,7 @@ bool Core::InitMainThread() {
#else
const char * path = "hack\\symbols.xml";
#endif
auto local_vif = dts::make_unique<DFHack::VersionInfoFactory>();
auto local_vif = std::make_unique<DFHack::VersionInfoFactory>();
std::cerr << "Identifying DF version.\n";
try
{
Expand All @@ -1517,7 +1517,7 @@ bool Core::InitMainThread() {
return false;
}
vif = std::move(local_vif);
auto local_p = dts::make_unique<DFHack::Process>(*vif);
auto local_p = std::make_unique<DFHack::Process>(*vif);
local_p->ValidateDescriptionOS();
vinfo = local_p->getDescriptor();

Expand Down
22 changes: 0 additions & 22 deletions library/include/MiscUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,28 +61,6 @@ namespace DFHack {
class color_ostream;
}

/*! \namespace dts
* std.reverse() == dts, The namespace that include forward compatible helpers
* which can be used from newer standards. The preprocessor check prefers
* standard version if one is available. The standard version gets imported with
* using.
*/
namespace dts {
// Check if lib supports the feature test macro or version is over c++14.
#if __cpp_lib_make_unique < 201304 && __cplusplus < 201402L
//! Insert c++14 make_unique to be forward compatible. Array versions are
//! missing
template<typename T, typename... Args>
typename std::enable_if<!std::is_array<T>::value, std::unique_ptr<T> >::type
make_unique(Args&&... args)
{
return std::unique_ptr<T>{new T{std::forward<Args>(args)...}};
}
#else /* >= c++14 */
using std::make_unique;
#endif
}

template <typename T>
void print_bits ( T val, std::ostream& out )
{
Expand Down
2 changes: 1 addition & 1 deletion library/modules/Graphic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ using namespace DFHack;

std::unique_ptr<Module> DFHack::createGraphic()
{
return dts::make_unique<Graphic>();
return std::make_unique<Graphic>();
}

bool Graphic::Register(DFTileSurface* (*func)(int,int))
Expand Down
2 changes: 1 addition & 1 deletion library/modules/Materials.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ bool DFHack::isStoneInorganic(int material)

std::unique_ptr<Module> DFHack::createMaterials()
{
return dts::make_unique<Materials>();
return std::make_unique<Materials>();
}

Materials::Materials()
Expand Down
2 changes: 1 addition & 1 deletion plugins/autofarm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ DFhackCExport command_result plugin_init(color_ostream& out, std::vector <Plugin
"Automatically manage farm crop selection.",
autofarm));
}
autofarmInstance = std::move(dts::make_unique<AutoFarm>());
autofarmInstance = std::move(std::make_unique<AutoFarm>());
autofarmInstance->load_state(out);
return CR_OK;
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/tailor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ static int do_cycle(color_ostream &out);
DFhackCExport command_result plugin_init(color_ostream &out, std::vector <PluginCommand> &commands) {
DEBUG(config,out).print("initializing %s\n", plugin_name);

tailor_instance = dts::make_unique<Tailor>();
tailor_instance = std::make_unique<Tailor>();

// provide a configuration interface for the plugin
commands.push_back(PluginCommand(
Expand Down

0 comments on commit 94727a0

Please sign in to comment.