Skip to content

Commit

Permalink
Add const to some functions
Browse files Browse the repository at this point in the history
  • Loading branch information
rikardfalkeborn authored and Vultraz committed Apr 17, 2017
1 parent 77184d4 commit 343eb9a
Show file tree
Hide file tree
Showing 10 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/addon/validation.cpp
Expand Up @@ -32,7 +32,7 @@ namespace {
/**
* Returns whether the given add-on name char is not whitelisted.
*/
inline bool operator()(char c)
inline bool operator()(char c) const
{
switch(c)
{
Expand Down
2 changes: 1 addition & 1 deletion src/ai/default/stage_rca.cpp
Expand Up @@ -72,7 +72,7 @@ config candidate_action_evaluation_loop::to_config() const

class desc_sorter_of_candidate_actions {
public:
bool operator()(const candidate_action_ptr &a, const candidate_action_ptr &b)
bool operator()(const candidate_action_ptr &a, const candidate_action_ptr &b) const
{
return a->get_max_score() > b->get_max_score();
}
Expand Down
2 changes: 1 addition & 1 deletion src/animated.hpp
Expand Up @@ -32,7 +32,7 @@ template<typename T>
class void_value
{
public:
const T operator()() { return T(); }
const T operator()() const { return T(); }
};

template<typename T, typename T_void_value=void_value<T> >
Expand Down
2 changes: 1 addition & 1 deletion src/arrow.hpp
Expand Up @@ -61,7 +61,7 @@ class arrow {
* If it doesn't exist or has missing images, you'll get "under construction"
* symbols instead of arrow graphics.
*/
std::string get_style() {return style_;}
std::string get_style() const {return style_;}
void set_style(const std::string& style);
///If you add more styles, you should look at move::update_arrow_style()
static const std::string STYLE_STANDARD;
Expand Down
2 changes: 1 addition & 1 deletion src/carryover.cpp
Expand Up @@ -164,7 +164,7 @@ void carryover_info::remove_side(const std::string& id) {
struct save_id_equals
{
save_id_equals(const std::string& val) : value (val) {}
bool operator () (carryover& v2)
bool operator () (carryover& v2) const
{
return value == v2.get_save_id();
}
Expand Down
2 changes: 1 addition & 1 deletion src/display.cpp
Expand Up @@ -2065,7 +2065,7 @@ void display::set_default_zoom()
}
}

bool display::tile_fully_on_screen(const map_location& loc)
bool display::tile_fully_on_screen(const map_location& loc) const
{
int x = get_location_x(loc);
int y = get_location_y(loc);
Expand Down
2 changes: 1 addition & 1 deletion src/display.hpp
Expand Up @@ -554,7 +554,7 @@ class display : public filter_context, public video2::draw_layering
events::generic_event& complete_redraw_event() { return complete_redraw_event_; }

/** Check if a tile is fully visible on screen. */
bool tile_fully_on_screen(const map_location& loc);
bool tile_fully_on_screen(const map_location& loc) const;

/** Checks if location @a loc or one of the adjacent tiles is visible on screen. */
bool tile_nearly_on_screen(const map_location &loc) const;
Expand Down
4 changes: 2 additions & 2 deletions src/formatter.hpp
Expand Up @@ -62,12 +62,12 @@ class formatter
}
#endif

std::string str() {
std::string str() const {
return stream_.str();
}

// Implicit x-value conversion to string
operator std::string()
operator std::string() const
#if HAVE_REF_QUALIFIERS
&&
#endif
Expand Down
4 changes: 2 additions & 2 deletions src/formula/function.cpp
Expand Up @@ -1094,7 +1094,7 @@ class zip_function : public function_expression {
struct indexer {
size_t i;
explicit indexer(size_t i) : i(i) {}
variant operator()(const variant& v) {
variant operator()(const variant& v) const {
if(i >= v.num_elements()) {
return variant();
} else {
Expand All @@ -1103,7 +1103,7 @@ class zip_function : public function_expression {
}
};
struct comparator {
bool operator()(const variant& a, const variant& b) {
bool operator()(const variant& a, const variant& b) const {
return a.num_elements() < b.num_elements();
}
};
Expand Down
4 changes: 2 additions & 2 deletions src/game_initialization/connect_engine.hpp
Expand Up @@ -92,7 +92,7 @@ class connect_engine
throw "No scenariodata found";
}
const std::set<std::string>& connected_users() const;
const std::vector<std::string>& user_team_names()
const std::vector<std::string>& user_team_names() const
{ return user_team_names_; }
std::vector<side_engine_ptr>& side_engines() { return side_engines_; }
const mp_game_settings& params() const { return params_; }
Expand Down Expand Up @@ -186,7 +186,7 @@ class side_engine
// The id of the side of the previous scenario that should control this side.
std::string previous_save_id() const
{ return (!cfg_["previous_save_id"].empty()) ? cfg_["previous_save_id"] : save_id(); }
const std::vector<controller_option>& controller_options()
const std::vector<controller_option>& controller_options() const
{ return controller_options_; }
const config& cfg() const { return cfg_; }
ng::controller controller() const { return controller_; }
Expand Down

0 comments on commit 343eb9a

Please sign in to comment.