mirror of
https://github.com/wesnoth/wesnoth
synced 2025-04-13 20:57:09 +00:00
Use boost::optional only on MacOS and remove has_optional_value
This commit is contained in:
parent
2679fec5f2
commit
7f3378d00c
|
@ -102,9 +102,9 @@ bool game_config_manager::init_game_config(FORCE_RELOAD_CONFIG force_reload)
|
|||
{
|
||||
// Add preproc defines according to the command line arguments.
|
||||
game_config::scoped_preproc_define multiplayer("MULTIPLAYER", cmdline_opts_.multiplayer);
|
||||
game_config::scoped_preproc_define test("TEST", utils::has_optional_value(cmdline_opts_.test));
|
||||
game_config::scoped_preproc_define test("TEST", cmdline_opts_.test.has_value());
|
||||
game_config::scoped_preproc_define mptest("MP_TEST", cmdline_opts_.mptest);
|
||||
game_config::scoped_preproc_define editor("EDITOR", utils::has_optional_value(cmdline_opts_.editor));
|
||||
game_config::scoped_preproc_define editor("EDITOR", cmdline_opts_.editor.has_value());
|
||||
game_config::scoped_preproc_define title_screen("TITLE_SCREEN",
|
||||
!cmdline_opts_.multiplayer && !cmdline_opts_.test && !cmdline_opts_.editor);
|
||||
|
||||
|
|
|
@ -676,7 +676,7 @@ bool game_launcher::play_render_image_mode()
|
|||
|
||||
bool game_launcher::has_load_data() const
|
||||
{
|
||||
return utils::has_optional_value(load_data_);
|
||||
return load_data_.has_value();
|
||||
}
|
||||
|
||||
bool game_launcher::load_game()
|
||||
|
|
|
@ -123,7 +123,7 @@ public:
|
|||
|
||||
bool is_regular_game_end() const
|
||||
{
|
||||
return utils::has_optional_value(gamestate().end_level_data_);
|
||||
return gamestate().end_level_data_.has_value();
|
||||
}
|
||||
|
||||
bool check_regular_game_end();
|
||||
|
|
|
@ -45,7 +45,7 @@ public:
|
|||
bool should_stop() const { return stop_condition_->should_stop(); }
|
||||
bool can_execute_command(const hotkey::ui_command& cmd) const;
|
||||
bool is_controlling_view() const {
|
||||
return utils::has_optional_value(vision_);
|
||||
return vision_.has_value();
|
||||
}
|
||||
bool allow_reset_replay() const { return reset_state_.get() != nullptr; }
|
||||
const std::shared_ptr<config>& get_reset_state() const { return reset_state_; }
|
||||
|
|
|
@ -94,7 +94,7 @@ struct preproc_define
|
|||
version_info deprecation_version;
|
||||
|
||||
bool is_deprecated() const {
|
||||
return utils::has_optional_value(deprecation_level);
|
||||
return deprecation_level.has_value();
|
||||
}
|
||||
|
||||
void write(config_writer&, const std::string&) const;
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
#include "global.hpp"
|
||||
|
||||
#ifdef HAVE_CXX17
|
||||
#ifndef __APPLE__
|
||||
#include <optional>
|
||||
#else
|
||||
#include <boost/optional.hpp>
|
||||
|
@ -23,7 +23,7 @@
|
|||
|
||||
namespace utils
|
||||
{
|
||||
#ifdef HAVE_CXX17
|
||||
#ifndef __APPLE__
|
||||
|
||||
using std::optional;
|
||||
using std::make_optional;
|
||||
|
@ -43,14 +43,4 @@ static const boost::none_t nullopt{boost::none_t::init_tag{}};
|
|||
|
||||
#endif
|
||||
|
||||
template<typename T>
|
||||
bool has_optional_value(const optional<T>& opt)
|
||||
{
|
||||
#if defined HAVE_CXX17 || BOOST_VERSION >= 106800
|
||||
return opt.has_value();
|
||||
#else
|
||||
return opt != nullopt;
|
||||
#endif
|
||||
}
|
||||
|
||||
} // end namespace utils
|
||||
|
|
Loading…
Reference in New Issue
Block a user