Skip to content

Commit

Permalink
Use unique_ptr instead of auto_ptr (deprecated in c++11)
Browse files Browse the repository at this point in the history
  • Loading branch information
Vultraz committed Mar 30, 2016
1 parent 3eb45c6 commit f849048
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 16 deletions.
8 changes: 4 additions & 4 deletions src/editor/action/action_item.cpp
Expand Up @@ -35,7 +35,7 @@ editor_action_item* editor_action_item::clone() const

editor_action* editor_action_item::perform(map_context& mc) const
{
std::auto_ptr<editor_action> undo(new editor_action_item_delete(loc_));
std::unique_ptr<editor_action> undo(new editor_action_item_delete(loc_));
perform_without_undo(mc);
return undo.release();
}
Expand All @@ -60,7 +60,7 @@ editor_action* editor_action_item_delete::perform(map_context& /*mc*/) const
// item_map& items = mc.get_items();
// item_map::const_item_iterator item_it = items.find(loc_);
//
// std::auto_ptr<editor_action> undo;
// std::unique_ptr<editor_action> undo;
// if (item_it != items.end()) {
// undo.reset(new editor_action_item(loc_, *item_it));
// perform_without_undo(mc);
Expand All @@ -87,7 +87,7 @@ editor_action_item_replace* editor_action_item_replace::clone() const

editor_action* editor_action_item_replace::perform(map_context& mc) const
{
std::auto_ptr<editor_action> undo(new editor_action_item_replace(new_loc_, loc_));
std::unique_ptr<editor_action> undo(new editor_action_item_replace(new_loc_, loc_));

perform_without_undo(mc);
return undo.release();
Expand Down Expand Up @@ -125,7 +125,7 @@ editor_action_item_facing* editor_action_item_facing::clone() const

editor_action* editor_action_item_facing::perform(map_context& mc) const
{
std::auto_ptr<editor_action> undo(new editor_action_item_facing(loc_, old_direction_, new_direction_));
std::unique_ptr<editor_action> undo(new editor_action_item_facing(loc_, old_direction_, new_direction_));
perform_without_undo(mc);
return undo.release();
}
Expand Down
4 changes: 2 additions & 2 deletions src/editor/action/action_label.cpp
Expand Up @@ -32,7 +32,7 @@ editor_action_label* editor_action_label::clone() const

editor_action* editor_action_label::perform(map_context& mc) const
{
std::auto_ptr<editor_action> undo;
std::unique_ptr<editor_action> undo;

const terrain_label *old_label = mc.get_labels().get_label(loc_);
if (old_label) {
Expand All @@ -59,7 +59,7 @@ editor_action_label_delete* editor_action_label_delete::clone() const

editor_action* editor_action_label_delete::perform(map_context& mc) const
{
std::auto_ptr<editor_action> undo;
std::unique_ptr<editor_action> undo;

const terrain_label* deleted = mc.get_labels().get_label(loc_);

Expand Down
8 changes: 4 additions & 4 deletions src/editor/action/action_unit.cpp
Expand Up @@ -38,7 +38,7 @@ editor_action_unit* editor_action_unit::clone() const

editor_action* editor_action_unit::perform(map_context& mc) const
{
std::auto_ptr<editor_action> undo(new editor_action_unit_delete(loc_));
std::unique_ptr<editor_action> undo(new editor_action_unit_delete(loc_));
perform_without_undo(mc);
return undo.release();
}
Expand All @@ -61,7 +61,7 @@ editor_action* editor_action_unit_delete::perform(map_context& mc) const
unit_map& units = mc.get_units();
unit_map::const_unit_iterator unit_it = units.find(loc_);

std::auto_ptr<editor_action> undo;
std::unique_ptr<editor_action> undo;
if (unit_it != units.end()) {
undo.reset(new editor_action_unit(loc_, *unit_it));
perform_without_undo(mc);
Expand All @@ -88,7 +88,7 @@ editor_action_unit_replace* editor_action_unit_replace::clone() const

editor_action* editor_action_unit_replace::perform(map_context& mc) const
{
std::auto_ptr<editor_action> undo(new editor_action_unit_replace(new_loc_, loc_));
std::unique_ptr<editor_action> undo(new editor_action_unit_replace(new_loc_, loc_));

perform_without_undo(mc);
return undo.release();
Expand Down Expand Up @@ -126,7 +126,7 @@ editor_action_unit_facing* editor_action_unit_facing::clone() const

editor_action* editor_action_unit_facing::perform(map_context& mc) const
{
std::auto_ptr<editor_action> undo(new editor_action_unit_facing(loc_, old_direction_, new_direction_));
std::unique_ptr<editor_action> undo(new editor_action_unit_facing(loc_, old_direction_, new_direction_));
perform_without_undo(mc);
return undo.release();
}
Expand Down
4 changes: 2 additions & 2 deletions src/editor/action/action_village.cpp
Expand Up @@ -31,7 +31,7 @@ editor_action_village* editor_action_village::clone() const

editor_action* editor_action_village::perform(map_context& mc) const
{
std::auto_ptr<editor_action> undo;
std::unique_ptr<editor_action> undo;

if(!mc.get_map().is_village(loc_)) return NULL;
std::vector<team>& teams = mc.get_teams();
Expand Down Expand Up @@ -69,7 +69,7 @@ editor_action_village_delete* editor_action_village_delete::clone() const

editor_action* editor_action_village_delete::perform(map_context& mc) const
{
std::auto_ptr<editor_action> undo;
std::unique_ptr<editor_action> undo;

const std::vector<team>& teams = mc.get_teams();
for(std::vector<team>::const_iterator i = teams.begin(); i != teams.end(); ++i) {
Expand Down
2 changes: 1 addition & 1 deletion src/gui/dialogs/dialog.cpp
Expand Up @@ -38,7 +38,7 @@ bool tdialog::show(CVideo& video, const unsigned auto_close_time)
return false;
}

std::auto_ptr<twindow> window(build_window(video));
std::unique_ptr<twindow> window(build_window(video));
assert(window.get());

post_build(*window);
Expand Down
2 changes: 1 addition & 1 deletion src/gui/widgets/pane.hpp
Expand Up @@ -161,7 +161,7 @@ class tpane : public twidget
unsigned item_id_generator_;

/** Helper to do the placement. */
std::auto_ptr<tplacer_> placer_;
std::unique_ptr<tplacer_> placer_;

/** Places the children on the pane. */
void place_children();
Expand Down
2 changes: 1 addition & 1 deletion src/server/game.cpp
Expand Up @@ -971,7 +971,7 @@ bool game::process_turn(simple_wml::document& data, const player_map::const_iter
continue;
}

std::auto_ptr<simple_wml::document> message(new simple_wml::document);
std::unique_ptr<simple_wml::document> message(new simple_wml::document);
simple_wml::node& turn = message->root().add_child("turn");
simple_wml::node& command = turn.add_child("command");
speak->copy_into(command.add_child("speak"));
Expand Down
2 changes: 1 addition & 1 deletion src/whiteboard/recruit.cpp
Expand Up @@ -176,7 +176,7 @@ unit_ptr recruit::create_corresponding_unit()
unit_ptr result(new unit(*type, side_num, real_unit));
result->set_movement(0, true);
result->set_attacks(0);
return result; //ownership gets transferred to returned auto_ptr copy
return result; //ownership gets transferred to returned unique_ptr copy
}

action::error recruit::check_validity() const
Expand Down

0 comments on commit f849048

Please sign in to comment.