From d3887e41a846d2ddd561d5dd84836345ab81502d Mon Sep 17 00:00:00 2001 From: Vaughn Cato Date: Wed, 9 Aug 2023 20:44:33 -0400 Subject: [PATCH] Change to ConstStringRef Made it use std::visit() instead of std::holds_alternative() --- include/ftxui/util/ref.hpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) 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_); } };