mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-06 18:08:10 +00:00
Added utils::has_optional_value
This commit is contained in:
parent
4b685a93e6
commit
ba7ea3ca98
@ -134,11 +134,7 @@ public:
|
||||
gamestate().end_level_data_.reset();
|
||||
}
|
||||
bool is_regular_game_end() const {
|
||||
#if defined HAVE_CXX17 || BOOST_VERSION >= 106800
|
||||
return gamestate().end_level_data_.has_value();
|
||||
#else
|
||||
return gamestate().end_level_data_ != utils::nullopt;
|
||||
#endif
|
||||
return utils::has_optional_value(gamestate().end_level_data_);
|
||||
}
|
||||
const end_level_data& get_end_level_data_const() const {
|
||||
return *gamestate().end_level_data_;
|
||||
|
@ -48,11 +48,7 @@ public:
|
||||
bool should_stop() const { return stop_condition_->should_stop(); }
|
||||
bool can_execute_command(const hotkey::hotkey_command& cmd, int index) const;
|
||||
bool is_controlling_view() const {
|
||||
#if defined HAVE_CXX17 || BOOST_VERSION >= 106800
|
||||
return vision_.has_value();
|
||||
#else
|
||||
return vision_ != utils::nullopt;
|
||||
#endif
|
||||
return utils::has_optional_value(vision_);
|
||||
}
|
||||
bool allow_reset_replay() const { return reset_state_.get() != nullptr; }
|
||||
const std::shared_ptr<config>& get_reset_state() const { return reset_state_; }
|
||||
|
@ -93,11 +93,7 @@ struct preproc_define
|
||||
version_info deprecation_version;
|
||||
|
||||
bool is_deprecated() const {
|
||||
#if defined HAVE_CXX17 || BOOST_VERSION >= 106800
|
||||
return deprecation_level.has_value();
|
||||
#else
|
||||
return deprecation_level != utils::nullopt;
|
||||
#endif
|
||||
return utils::has_optional_value(deprecation_level);
|
||||
}
|
||||
|
||||
void write(config_writer&, const std::string&) const;
|
||||
|
@ -1,14 +1,14 @@
|
||||
/*
|
||||
Copyright (C) 2020 by the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
Copyright (C) 2020 by the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY.
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY.
|
||||
|
||||
See the COPYING file for more details.
|
||||
See the COPYING file for more details.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
@ -36,4 +36,15 @@ using boost::optional;
|
||||
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…
x
Reference in New Issue
Block a user