From eef1ac9339cf7cd2c01933f67b0d38eee4cb0a02 Mon Sep 17 00:00:00 2001 From: terik23 Date: Mon, 22 Apr 2019 20:51:07 +0500 Subject: [PATCH] refactoring --- include/magic_enum.hpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/include/magic_enum.hpp b/include/magic_enum.hpp index 005f81d..7d3fc9a 100644 --- a/include/magic_enum.hpp +++ b/include/magic_enum.hpp @@ -326,9 +326,8 @@ namespace ops { template , typename = detail::enable_if_enum_t> std::ostream& operator<<(std::ostream& os, E value) { static_assert(std::is_enum_v, "magic_enum::ops::operator<< requires enum type."); - const auto name = detail::name_impl(static_cast(value)); - if (!name.empty()) { + if (auto name = detail::name_impl(static_cast(value)); !name.empty()) { os << name; } @@ -340,8 +339,7 @@ std::ostream& operator<<(std::ostream& os, std::optional value) { static_assert(std::is_enum_v, "magic_enum::ops::operator<< requires enum type."); if (value.has_value()) { - const auto name = detail::name_impl(static_cast(value.value())); - if (!name.empty()) { + if (auto name = detail::name_impl(static_cast(value.value())); !name.empty()) { os << name; } }