[wesnoth-commits] [wesnoth/wesnoth] ee28ac: Unit: converted upkeep handling to std::variant (#...
Charles Dang
noreply at github.com
Tue Jan 19 03:24:22 UTC 2021
Branch: refs/heads/master
Home: https://github.com/wesnoth/wesnoth
Commit: ee28ac0e264fde7bb1402486320d9de31eed9df5
https://github.com/wesnoth/wesnoth/commit/ee28ac0e264fde7bb1402486320d9de31eed9df5
Author: Charles Dang <exodia339 at gmail.com>
Date: 2021-01-19 (Tue, 19 Jan 2021)
Changed paths:
M src/actions/advancement.cpp
M src/actions/advancement.hpp
M src/scripting/lua_unit.cpp
M src/units/filter.cpp
M src/units/unit.cpp
M src/units/unit.hpp
A src/utils/variant.hpp
Log Message:
-----------
Unit: converted upkeep handling to std::variant (#5459)
Since MacOS doesn't properly support std::variant (it has problems with std::visit specifically) unless it targets MacOS 10.14 or later, this adds a wrapper class that uses std::variant and friends on all platforms except MacOS, where boost::variant is used. The USING_BOOST_VARIANT define is then defined on MacOS and should be used to guard for code (such as inheriting from boost::static_visitor) that isn't needed with std::variant.
unit::upkeep_parser_visitor is still unconditionally boost::variant-compatible since it's used by const_attribute_value::apply_visitor, and configs still use boost::variant under the hood.
Additionally, these visitors are used in multiple places, so I can't convert them to lambas in-class.
Finally, I used brace-init for the upkeep types and visitors to make it clearer these are not functions.
As for the static_cast changes, for some reason mingw had issues converting double or long long int to the upkeep variant (which keeps an int specifically). No idea why it had no problem dealing with this with boost::variant.
More information about the Commits
mailing list