diff --git a/src/game_config_manager.cpp b/src/game_config_manager.cpp index f3ffd80abfb..28d9e92ed88 100644 --- a/src/game_config_manager.cpp +++ b/src/game_config_manager.cpp @@ -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); diff --git a/src/game_launcher.cpp b/src/game_launcher.cpp index 95438caf27a..a2287882772 100644 --- a/src/game_launcher.cpp +++ b/src/game_launcher.cpp @@ -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() diff --git a/src/play_controller.hpp b/src/play_controller.hpp index f9d608aa381..abdbc62f761 100644 --- a/src/play_controller.hpp +++ b/src/play_controller.hpp @@ -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(); diff --git a/src/replay_controller.hpp b/src/replay_controller.hpp index 5202e192ce7..c5f53dc9884 100644 --- a/src/replay_controller.hpp +++ b/src/replay_controller.hpp @@ -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_; } diff --git a/src/serialization/preprocessor.hpp b/src/serialization/preprocessor.hpp index 96a932b296a..4fe226661b1 100644 --- a/src/serialization/preprocessor.hpp +++ b/src/serialization/preprocessor.hpp @@ -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; diff --git a/src/utils/optional_fwd.hpp b/src/utils/optional_fwd.hpp index 5996304886f..3eacbb05955 100644 --- a/src/utils/optional_fwd.hpp +++ b/src/utils/optional_fwd.hpp @@ -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