From ae7aabf63d61564d6a0c252d2492c4c6b8f6b601 Mon Sep 17 00:00:00 2001 From: neargye Date: Sun, 8 Nov 2020 22:00:23 +0200 Subject: [PATCH] update comments --- example/example_custom_name.cpp | 20 ++++++++++---------- include/magic_enum.hpp | 6 +++--- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/example/example_custom_name.cpp b/example/example_custom_name.cpp index 5e71720..5fd62e6 100644 --- a/example/example_custom_name.cpp +++ b/example/example_custom_name.cpp @@ -36,9 +36,9 @@ constexpr std::string_view magic_enum::customize::enum_name(Color value) case Color::BLUE: return "The BLUE"; case Color::GREEN: - return {}; // "Empty string for default value." + return {}; // Empty string for default value. } - return {}; // "Empty string for unknow value." + return {}; // Empty string for unknow value. } enum class Numbers : int { One, Two, Three }; @@ -51,21 +51,21 @@ constexpr std::string_view magic_enum::customize::enum_name(Numbers val case Numbers::One: return "the one"; default: - return {}; // "Empty string for default or unknow value." + return {}; // Empty string for default or unknow value. } } int main() { - std::cout << magic_enum::enum_name(Color::RED) << std::endl; // "the red color" - std::cout << magic_enum::enum_name(Color::BLUE) << std::endl; // "The BLUE" - std::cout << magic_enum::enum_name(Color::GREEN) << std::endl; // "GREEN" + std::cout << magic_enum::enum_name(Color::RED) << std::endl; // the red color + std::cout << magic_enum::enum_name(Color::BLUE) << std::endl; // The BLUE + std::cout << magic_enum::enum_name(Color::GREEN) << std::endl; // GREEN std::cout << std::boolalpha; - std::cout << (magic_enum::enum_cast("the red color").value() == Color::RED) << std::endl; // "true" + std::cout << (magic_enum::enum_cast("the red color").value() == Color::RED) << std::endl; // true - std::cout << magic_enum::enum_name(Numbers::One) << std::endl; // "the one" - std::cout << magic_enum::enum_name(Numbers::Two) << std::endl; // "Two" - std::cout << magic_enum::enum_name(Numbers::Three) << std::endl; // "Three" + std::cout << magic_enum::enum_name(Numbers::One) << std::endl; // the one + std::cout << magic_enum::enum_name(Numbers::Two) << std::endl; // Two + std::cout << magic_enum::enum_name(Numbers::Three) << std::endl; // Three return 0; } diff --git a/include/magic_enum.hpp b/include/magic_enum.hpp index ac16305..68679ea 100644 --- a/include/magic_enum.hpp +++ b/include/magic_enum.hpp @@ -99,14 +99,14 @@ template using optional = std::optional; #endif -// If need another optional type, define the macro MAGIC_ENUM_USING_ALIAS_STRING_VIEW. +// If need another string_view type, define the macro MAGIC_ENUM_USING_ALIAS_STRING_VIEW. #if defined(MAGIC_ENUM_USING_ALIAS_STRING_VIEW) MAGIC_ENUM_USING_ALIAS_STRING_VIEW #else using string_view = std::string_view; #endif -// If need another optional type, define the macro MAGIC_ENUM_USING_ALIAS_STRING. +// If need another string type, define the macro MAGIC_ENUM_USING_ALIAS_STRING. #if defined(MAGIC_ENUM_USING_ALIAS_STRING) MAGIC_ENUM_USING_ALIAS_STRING #else @@ -134,7 +134,7 @@ static_assert(MAGIC_ENUM_RANGE_MAX < (std::numeric_limits::max)(), static_assert(MAGIC_ENUM_RANGE_MAX > MAGIC_ENUM_RANGE_MIN, "MAGIC_ENUM_RANGE_MAX must be greater than MAGIC_ENUM_RANGE_MIN."); -// If need cunstom names for enum type, add specialization enum_name for necessary enum type. +// If need cunstom names for enum, add specialization enum_name for necessary enum type. template constexpr string_view enum_name(E) noexcept { static_assert(std::is_enum_v, "magic_enum::customize::enum_name requires enum type.");