C++17: Replace Glib::Variant with std::variant or std::any?
@murrayc
Submitted by Murray Cumming Link to original bug (#769260)
Description
When we can use C++17, and probably when we can break ABI, do we want to use std::variant or std::any instead of our wrapper of GVariant?
Maybe std::any
and std::any_cast<>
is the best equivalent for Glib::VariantBase<>
and Glib::VariantBase::cast_dynamic<>
.
std::variant<>
would need to be aliased like so:
using OurVariant = std::variant<int, guint, char, std::string, enumtyp1, enumtype2, etc)
which seems impossible to ever get right. It does have std::get<>
and std::get_if<>
which would be similar to using Glib::VariantBase::cast_dynamic<>
: http://en.cppreference.com/w/cpp/utility/variant/get
However, we should make sure that we don't have any API that exposes variants unnecessarily. We have already marked some for removal at the next ABI break, and I guess that some more could be changed to be templated methods that only use variants internally.