diff --git a/include/ftxui/util/ref.hpp b/include/ftxui/util/ref.hpp index d8f0bae74..59b04bd19 100644 --- a/include/ftxui/util/ref.hpp +++ b/include/ftxui/util/ref.hpp @@ -105,12 +105,13 @@ class ConstStringRef { const std::string_view getStringView() const { - if ( std::holds_alternative(variant_) ) - return std::get(variant_); - else if ( std::holds_alternative(variant_) ) - return *std::get(variant_); - else if ( std::holds_alternative(variant_) ) - return std::get(variant_); + struct Fn { + std::string_view operator()(std::string_view x) const { return x; } + std::string_view operator()(std::string &x) const { return x; } + std::string_view operator()(std::string *x) const { return *x; } + }; + + return std::visit(Fn(), variant_); } };