Skip to content

Commit

Permalink
Further boost cleanup
Browse files Browse the repository at this point in the history
* Removed more unnecessary includes
* Used std::swap instead of boost::swap in fake_unit_ptr. This is since unit_ptr (the type of `unit_` here)
  is now just a shared_ptr instead of a boost::intrusive_ptr.
* Used std::gcd instead of boost::integer::gcd
  • Loading branch information
Vultraz committed Jan 23, 2021
1 parent de8ad23 commit 0c2134a
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 41 deletions.
2 changes: 0 additions & 2 deletions src/chat_events.cpp
Expand Up @@ -22,8 +22,6 @@
#include "preferences/general.hpp"
#include "preferences/game.hpp"

#include <boost/range/algorithm/find_if.hpp>

static lg::log_domain log_engine("engine");
#define ERR_NG LOG_STREAM(err, log_engine)
#define LOG_NG LOG_STREAM(info, log_engine)
Expand Down
3 changes: 0 additions & 3 deletions src/config_attribute_value.hpp
Expand Up @@ -41,9 +41,6 @@
#include <type_traits>
#include <memory>

#include <boost/exception/exception.hpp>
#include <boost/range/iterator_range.hpp>

class enum_tag;

/**
Expand Down
4 changes: 1 addition & 3 deletions src/fake_unit_ptr.cpp
Expand Up @@ -19,8 +19,6 @@
#include "units/unit.hpp"
#include "units/ptr.hpp"

#include <boost/swap.hpp>

fake_unit_ptr::fake_unit_ptr() : unit_(), my_manager_(nullptr) {}
fake_unit_ptr::fake_unit_ptr(const internal_ptr & u) : unit_(u), my_manager_(nullptr) {}
fake_unit_ptr::fake_unit_ptr(const internal_ptr & u, fake_unit_manager * mgr) : unit_(u), my_manager_(nullptr)
Expand All @@ -40,7 +38,7 @@ fake_unit_ptr::fake_unit_ptr(fake_unit_ptr && ptr)
}

void fake_unit_ptr::swap (fake_unit_ptr & o) {
boost::swap(unit_, o.unit_);
std::swap(unit_, o.unit_);
std::swap(my_manager_, o.my_manager_);
}

Expand Down
14 changes: 2 additions & 12 deletions src/gui/dialogs/preferences_dialog.cpp
Expand Up @@ -57,13 +57,8 @@
#include "gui/widgets/toggle_button.hpp"
#include "gui/widgets/window.hpp"

#if BOOST_VERSION >= 106700
#include <boost/integer/common_factor_rt.hpp>
#else
#include <boost/math/common_factor_rt.hpp>
#endif

#include <functional>
#include <numeric>

namespace gui2
{
Expand Down Expand Up @@ -142,12 +137,7 @@ void preferences_dialog::set_resolution_list(menu_button& res_list)
config option;
option["label"] = formatter() << res.x << font::unicode_multiplication_sign << res.y;

#if BOOST_VERSION >= 106700
const int div = boost::integer::gcd(res.x, res.y);
#else
const int div = boost::math::gcd(res.x, res.y);
#endif

const int div = std::gcd(12, 4);
const int x_ratio = res.x / div;
const int y_ratio = res.y / div;

Expand Down
21 changes: 4 additions & 17 deletions src/gui/widgets/slider.cpp
Expand Up @@ -29,12 +29,7 @@
#include "wml_exception.hpp"

#include <functional>

#if BOOST_VERSION >= 106700
#include <boost/integer/common_factor_rt.hpp>
#else
#include <boost/math/common_factor_rt.hpp>
#endif
#include <numeric>

#define LOG_SCOPE_HEADER get_control_type() + " [" + id() + "] " + __func__
#define LOG_HEADER LOG_SCOPE_HEADER + ':'
Expand Down Expand Up @@ -265,12 +260,7 @@ void slider::set_value_range(int min_value, int max_value)
int diff = max_value - min_value;
int old_value = get_value();

#if BOOST_VERSION >= 106700
step_size_ = boost::integer::gcd(diff, step_size_);
#else
step_size_ = boost::math::gcd(diff, step_size_);
#endif

step_size_ = std::gcd(diff, step_size_);
minimum_value_ = min_value;

slider_set_item_last(diff / step_size_);
Expand All @@ -289,11 +279,8 @@ void slider::set_step_size(int step_size)
const int range_diff = get_item_count() - 1;
const int old_value = get_value();

#if BOOST_VERSION >= 106700
step_size_ = boost::integer::gcd(range_diff, step_size);
#else
step_size_ = boost::math::gcd(range_diff, step_size);
#endif
step_size_ = std::gcd(range_diff, step_size);

slider_set_item_last(range_diff / step_size_);
set_value(old_value);

Expand Down
3 changes: 1 addition & 2 deletions src/log.cpp
Expand Up @@ -21,12 +21,11 @@

#include "log.hpp"

#include <boost/date_time.hpp>

#include <map>
#include <sstream>
#include <ctime>
#include <mutex>
#include <iomanip>

namespace {

Expand Down
2 changes: 0 additions & 2 deletions src/team.cpp
Expand Up @@ -35,8 +35,6 @@
#include "units/types.hpp"
#include "whiteboard/side_actions.hpp"

#include <boost/dynamic_bitset.hpp>

static lg::log_domain log_engine("engine");
#define DBG_NG LOG_STREAM(debug, log_engine)
#define LOG_NG LOG_STREAM(info, log_engine)
Expand Down

0 comments on commit 0c2134a

Please sign in to comment.