From: Vsevolod Stakhov Date: Mon, 18 Jan 2021 20:19:51 +0000 (+0000) Subject: [Project] Use string_view to constexpr variant unpacking X-Git-Tag: 3.0~750 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=5d5ded1efc2efb1f68b6f1b492b8bee40e0d971a;p=rspamd.git [Project] Use string_view to constexpr variant unpacking --- diff --git a/src/libserver/css/css_selector.hxx b/src/libserver/css/css_selector.hxx index 273ff603e..4c12b3b41 100644 --- a/src/libserver/css/css_selector.hxx +++ b/src/libserver/css/css_selector.hxx @@ -47,9 +47,9 @@ struct css_selector { return std::nullopt; } - std::optional to_string (void) const { + constexpr std::optional to_string (void) const { if (type == selector_type::SELECTOR_ELEMENT) { - return std::get(value); + return std::string_view(std::get(value)); } return std::nullopt; } diff --git a/src/libserver/css/css_value.hxx b/src/libserver/css/css_value.hxx index e750d775e..fca0e0433 100644 --- a/src/libserver/css/css_value.hxx +++ b/src/libserver/css/css_value.hxx @@ -95,9 +95,9 @@ struct css_value { return std::nullopt; } - std::optional to_string (void) const { + constexpr std::optional to_string (void) const { if (type == css_value_type::CSS_VALUE_STRING) { - return std::get(value); + return std::string_view(std::get(value)); } return std::nullopt;