Skip to content

Commit

Permalink
Removed C++11 include guards
Browse files Browse the repository at this point in the history
This also expands the OVERRIDE compatibility macro (FINAL was not used).
  • Loading branch information
Vultraz committed Mar 31, 2016
1 parent 7f1dd72 commit cf6fa69
Show file tree
Hide file tree
Showing 53 changed files with 345 additions and 428 deletions.
2 changes: 0 additions & 2 deletions src/config.cpp
Expand Up @@ -464,7 +464,6 @@ config& config::operator=(const config& cfg)
return *this;
}

#ifdef HAVE_CXX11
config::config(config &&cfg):
values(std::move(cfg.values)),
children(std::move(cfg.children)),
Expand All @@ -478,7 +477,6 @@ config &config::operator=(config &&cfg)
swap(cfg);
return *this;
}
#endif

bool config::valid_id(const std::string& id)
{
Expand Down
17 changes: 0 additions & 17 deletions src/config.hpp
Expand Up @@ -75,27 +75,15 @@ class config
*/
void check_valid(const config &cfg) const;

#ifndef HAVE_CXX11
struct safe_bool_impl { void nonnull() {} };
/**
* Used as the return type of the conversion operator for boolean contexts.
* Needed, since the compiler would otherwise consider the following
* conversion (C legacy): cfg["abc"] -> "abc"[bool(cfg)] -> 'b'
*/
typedef void (safe_bool_impl::*safe_bool)();
#endif

public:
// Create an empty node.
config();

config(const config &);
config &operator=(const config &);

#ifdef HAVE_CXX11
config(config &&);
config &operator=(config &&);
#endif

/**
* Creates a config object with an empty child of name @a child.
Expand All @@ -107,13 +95,8 @@ class config
// Verifies that the string can be used as an attribute or tag name
static bool valid_id(const std::string& id);

#ifdef HAVE_CXX11
explicit operator bool() const
{ return this != &invalid; }
#else
operator safe_bool() const
{ return this != &invalid ? &safe_bool_impl::nonnull : NULL; }
#endif

typedef std::vector<config*> child_list;
typedef std::map<std::string,child_list> child_map;
Expand Down
16 changes: 1 addition & 15 deletions src/fake_unit_ptr.hpp
Expand Up @@ -67,24 +67,10 @@ private :
internal_ptr unit_; //!< Internal unit pointer.
fake_unit_manager * my_manager_; //!< Raw pointer to the manager.

#ifndef HAVE_CXX11
struct safe_bool_impl { void nonnull() {} };
/**
* Used as t he return type of the conversion operator for boolean contexts.
* Needed, since the compiler would otherwise consider the following
* conversion (C legacy): cfg["abc"] -> "abc"[bool(cfg)] -> 'b'
*/
typedef void (safe_bool_impl::*safe_bool)();
#endif

public:
#ifdef HAVE_CXX11

explicit operator bool() const
{ return unit_.get(); }
#else
operator safe_bool() const
{ return unit_ ? &safe_bool_impl::nonnull : NULL; }
#endif
};

#endif
24 changes: 0 additions & 24 deletions src/global.hpp
Expand Up @@ -43,30 +43,6 @@

#endif //_MSC_VER

/**
* Enable C++11 support in some parts of the code.
*
* These parts \em must also work without C++11, since Wesnoth still uses C++98
* as the official C++ version.
*
* @note Older versions of GCC don't define the proper version for
* @c __cplusplus, but have their own test macro. That test is omitted since
* the amount of support for these compilers depends a lot on the exact
* compiler version. If you want to enable it for these compilers simply define
* the macro manually.
*/
#if (__cplusplus >= 201103L)
#define HAVE_CXX11
#endif

#ifdef HAVE_CXX11
#define FINAL final
#define OVERRIDE override
#else
#define FINAL
#define OVERRIDE
#endif

#ifdef NDEBUG
/*
* Wesnoth uses asserts to avoid undefined behaviour. For example, to make sure
Expand Down
13 changes: 0 additions & 13 deletions src/gui/auxiliary/filter.hpp
Expand Up @@ -38,26 +38,13 @@ inline bool sort(const tpane::titem& lhs,
const std::string& tag,
const bool ascending)
{
#ifdef HAVE_CXX11
if(ascending) {
return lexical_cast<T>(lhs.tags.at(tag))
< lexical_cast<T>(rhs.tags.at(tag));
} else {
return lexical_cast<T>(lhs.tags.at(tag))
> lexical_cast<T>(rhs.tags.at(tag));
}
#else
typedef std::map<std::string,std::string>::const_iterator iterator;
iterator lhs_it = lhs.tags.find(tag), rhs_it = rhs.tags.find(tag);
if(lhs_it == lhs.tags.end() || rhs_it == rhs.tags.end()) {
throw std::out_of_range("Key »" + tag + "« doesn't exist.");
}
if(ascending) {
return lexical_cast<T>(*lhs_it) < lexical_cast<T>(*rhs_it);
} else {
return lexical_cast<T>(*lhs_it) > lexical_cast<T>(*rhs_it);
}
#endif
}

/**
Expand Down
8 changes: 4 additions & 4 deletions src/gui/widgets/button.hpp
Expand Up @@ -37,13 +37,13 @@ class tbutton : public tcontrol, public tclickable_
/***** ***** ***** ***** Inherited ***** ***** ***** *****/

/** See @ref tcontrol::set_active. */
virtual void set_active(const bool active) OVERRIDE;
virtual void set_active(const bool active) override;

/** See @ref tcontrol::get_active. */
virtual bool get_active() const OVERRIDE;
virtual bool get_active() const override;

/** See @ref tcontrol::get_state. */
virtual unsigned get_state() const OVERRIDE;
virtual unsigned get_state() const override;

/** Inherited from tclickable. */
void connect_click_handler(const event::tsignal_function& signal)
Expand Down Expand Up @@ -96,7 +96,7 @@ class tbutton : public tcontrol, public tclickable_
int retval_;

/** See @ref tcontrol::get_control_type. */
virtual const std::string& get_control_type() const OVERRIDE;
virtual const std::string& get_control_type() const override;

/***** ***** ***** signal handlers ***** ****** *****/

Expand Down
14 changes: 7 additions & 7 deletions src/gui/widgets/combobox.hpp
Expand Up @@ -36,13 +36,13 @@ class tcombobox : public tcontrol, public tselectable_
/***** ***** ***** ***** Inherited ***** ***** ***** *****/

/** See @ref tcontrol::set_active. */
virtual void set_active(const bool active) OVERRIDE;
virtual void set_active(const bool active) override;

/** See @ref tcontrol::get_active. */
virtual bool get_active() const OVERRIDE;
virtual bool get_active() const override;

/** See @ref tcontrol::get_state. */
virtual unsigned get_state() const OVERRIDE;
virtual unsigned get_state() const override;

/** Inherited from tclickable. */
void connect_click_handler(const event::tsignal_function& signal)
Expand All @@ -69,13 +69,13 @@ class tcombobox : public tcontrol, public tselectable_
boost::function<void(twidget&)> callback_state_change_;

/** Inherited from tselectable_ */
virtual unsigned get_value() const OVERRIDE { return selected_; }
virtual unsigned get_value() const override { return selected_; }

/** Inherited from tselectable_ */
virtual void set_value(const unsigned value ) OVERRIDE { set_selected(value); }
virtual void set_value(const unsigned value ) override { set_selected(value); }

/** Inherited from tselectable_ */
virtual unsigned num_states() const OVERRIDE { return values_.size(); }
virtual unsigned num_states() const override { return values_.size(); }

/** Inherited from tselectable_ */
virtual void set_callback_state_change(boost::function<void(twidget&)> callback)
Expand Down Expand Up @@ -126,7 +126,7 @@ class tcombobox : public tcontrol, public tselectable_
boost::function<void(twidget&)> selected_callback_;

/** See @ref tcontrol::get_control_type. */
virtual const std::string& get_control_type() const OVERRIDE;
virtual const std::string& get_control_type() const override;

/***** ***** ***** signal handlers ***** ****** *****/

Expand Down
42 changes: 21 additions & 21 deletions src/gui/widgets/container.hpp
Expand Up @@ -53,7 +53,7 @@ class tcontainer_ : public tcontrol
/***** ***** ***** ***** layout functions ***** ***** ***** *****/

/** See @ref twidget::layout_initialise. */
virtual void layout_initialise(const bool full_initialisation) OVERRIDE;
virtual void layout_initialise(const bool full_initialisation) override;

/**
* Tries to reduce the width of a container.
Expand All @@ -65,10 +65,10 @@ class tcontainer_ : public tcontrol
void reduce_width(const unsigned maximum_width);

/** See @ref twidget::request_reduce_width. */
virtual void request_reduce_width(const unsigned maximum_width) OVERRIDE;
virtual void request_reduce_width(const unsigned maximum_width) override;

/** See @ref twidget::demand_reduce_width. */
virtual void demand_reduce_width(const unsigned maximum_width) OVERRIDE;
virtual void demand_reduce_width(const unsigned maximum_width) override;

/**
* Tries to reduce the height of a container.
Expand All @@ -80,75 +80,75 @@ class tcontainer_ : public tcontrol
void reduce_height(const unsigned maximum_height);

/** See @ref twidget::request_reduce_height. */
virtual void request_reduce_height(const unsigned maximum_height) OVERRIDE;
virtual void request_reduce_height(const unsigned maximum_height) override;

/** See @ref twidget::demand_reduce_height. */
virtual void demand_reduce_height(const unsigned maximum_height) OVERRIDE;
virtual void demand_reduce_height(const unsigned maximum_height) override;

private:
/** See @ref twidget::calculate_best_size. */
virtual tpoint calculate_best_size() const OVERRIDE;
virtual tpoint calculate_best_size() const override;

public:
/** See @ref twidget::can_wrap. */
virtual bool can_wrap() const OVERRIDE;
virtual bool can_wrap() const override;

/** See @ref twidget::place. */
virtual void place(const tpoint& origin, const tpoint& size) OVERRIDE;
virtual void place(const tpoint& origin, const tpoint& size) override;

/***** ***** ***** ***** Inherited ***** ***** ***** *****/

/** See @ref twidget::has_widget. */
virtual bool has_widget(const twidget& widget) const OVERRIDE;
virtual bool has_widget(const twidget& widget) const override;

/** See @ref twidget::set_origin. */
virtual void set_origin(const tpoint& origin) OVERRIDE;
virtual void set_origin(const tpoint& origin) override;

/** See @ref twidget::set_visible_rectangle. */
virtual void set_visible_rectangle(const SDL_Rect& rectangle) OVERRIDE;
virtual void set_visible_rectangle(const SDL_Rect& rectangle) override;

/** See @ref twidget::impl_draw_children. */
virtual void impl_draw_children(surface& frame_buffer,
int x_offset,
int y_offset) OVERRIDE;
int y_offset) override;

protected:
/** See @ref twidget::layout_children. */
virtual void layout_children() OVERRIDE;
virtual void layout_children() override;

/** See @ref twidget::child_populate_dirty_list. */
virtual void
child_populate_dirty_list(twindow& caller,
const std::vector<twidget*>& call_stack) OVERRIDE;
const std::vector<twidget*>& call_stack) override;

public:
/** See @ref twidget::find_at. */
virtual twidget* find_at(const tpoint& coordinate,
const bool must_be_active) OVERRIDE;
const bool must_be_active) override;

/** See @ref twidget::find_at. */
virtual const twidget* find_at(const tpoint& coordinate,
const bool must_be_active) const OVERRIDE;
const bool must_be_active) const override;

/** See @ref twidget::find. */
twidget* find(const std::string& id, const bool must_be_active) OVERRIDE;
twidget* find(const std::string& id, const bool must_be_active) override;

/** See @ref twidget::find. */
const twidget* find(const std::string& id,
const bool must_be_active) const OVERRIDE;
const bool must_be_active) const override;

/** See @ref tcontrol::set_active. */
virtual void set_active(const bool active) OVERRIDE;
virtual void set_active(const bool active) override;

/** See @ref twidget::disable_click_dismiss. */
bool disable_click_dismiss() const OVERRIDE;
bool disable_click_dismiss() const override;

/**
* See @ref twidget::create_walker.
*
* @todo Implement properly.
*/
virtual iterator::twalker_* create_walker() OVERRIDE
virtual iterator::twalker_* create_walker() override
{
return NULL;
}
Expand Down

0 comments on commit cf6fa69

Please sign in to comment.