From 6ea17a9474a2102d86004ada7eb0e58489edbd28 Mon Sep 17 00:00:00 2001 From: David Dight Date: Sat, 6 Apr 2024 08:40:22 +1100 Subject: [PATCH] pre-v1.0g-update --- examples/example.cpp | 12 ++++++------ examples/unittests.cpp | 4 ++-- include/fix8/conjure_enum.hpp | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/examples/example.cpp b/examples/example.cpp index 1c190b8b..a54d6a1f 100644 --- a/examples/example.cpp +++ b/examples/example.cpp @@ -44,10 +44,10 @@ using namespace std::literals::string_literals; using namespace FIX8; //----------------------------------------------------------------------------------------- -enum class component : int { scheme, authority, userinfo, user, password, host, port, path=12, test=path, query, fragment }; -enum component1 : int { scheme, authority, userinfo, user, password, host, port, path=12, query, fragment }; -enum class numbers : int { zero, one, two, three, four, five, six, seven, eight, nine }; -enum class numbers1 : int { zero1=4, one1=3, two1=2, three1, four1, five1, six1, seven1, eight1, nine1 }; +enum class component { scheme, authority, userinfo, user, password, host, port, path=12, test=path, query, fragment }; +enum component1 { scheme, authority, userinfo, user, password, host, port, path=12, query, fragment }; +enum class numbers { zero, one, two, three, four, five, six, seven, eight, nine }; +enum class numbers1 { zero1=4, one1=3, two1=2, three1, four1, five1, six1, seven1, eight1, nine1 }; //----------------------------------------------------------------------------------------- template @@ -136,8 +136,8 @@ int main(void) enum_bitset c(15); std::cout << c << '\n'; #if __has_include() - for(const auto [a, b] : conjure_enum::scoped_entries) - std::cout << std::format("{:9} {}\n", a, b); + for(const auto [a2, b2] : conjure_enum::scoped_entries) + std::cout << std::format("{:9} {}\n", a2, b2); for(const auto [value, str] : conjure_enum::entries) // scoped std::cout << std::format("{:<2} {}\n", static_cast(value), str); for(const auto [value, str] : conjure_enum::sorted_entries) // scoped diff --git a/examples/unittests.cpp b/examples/unittests.cpp index 027a40a1..b7c0730a 100644 --- a/examples/unittests.cpp +++ b/examples/unittests.cpp @@ -38,8 +38,8 @@ using namespace std::literals::string_view_literals; using namespace std::literals::string_literals; //----------------------------------------------------------------------------------------- -enum class component : int { scheme, authority, userinfo, user, password, host, port, path=12, test=path, query, fragment }; -enum component1 : int { scheme, authority, userinfo, user, password, host, port, path=12, query, fragment }; +enum class component { scheme, authority, userinfo, user, password, host, port, path=12, test=path, query, fragment }; +enum component1 { scheme, authority, userinfo, user, password, host, port, path=12, query, fragment }; enum class numbers { zero, one, two, three, four, five, FIVE=five, six, seven, eight, nine }; //----------------------------------------------------------------------------------------- diff --git a/include/fix8/conjure_enum.hpp b/include/fix8/conjure_enum.hpp index ab01bc06..9ef4cc5e 100644 --- a/include/fix8/conjure_enum.hpp +++ b/include/fix8/conjure_enum.hpp @@ -89,7 +89,7 @@ class fixed_string final constexpr fixed_string(std::string_view sv, std::integer_sequence) noexcept : _buff{sv[C]..., 0} {} public: - constexpr fixed_string(std::string_view sv) noexcept : fixed_string{sv.data(), std::make_integer_sequence{}} {} + explicit constexpr fixed_string(std::string_view sv) noexcept : fixed_string{sv.data(), std::make_integer_sequence{}} {} constexpr fixed_string() = delete; constexpr std::string_view get() const noexcept { return { _buff.data(), N }; } constexpr operator std::string_view() const noexcept { return get(); } @@ -222,7 +222,7 @@ class conjure_enum final if (constexpr auto ep { from.rfind(get_spec<0,0>()) }; ep != std::string_view::npos && from[ep + get_spec<0,0>().size()] != '(') { constexpr std::string_view result { from.substr(ep + get_spec<0,0>().size()) }; - if (constexpr auto lc { result.find_first_of(get_spec<1,0>()) }; lc != std::string_view::npos) + if constexpr (constexpr auto lc { result.find_first_of(get_spec<1,0>()) }; lc != std::string_view::npos) return result.substr(0, lc); } return {}; @@ -252,10 +252,10 @@ class conjure_enum final static constexpr std::string_view type_name() noexcept { constexpr std::string_view from{tpeek()}; - if (constexpr auto ep { from.rfind(get_spec<0,1>()) }; ep != std::string_view::npos) + if constexpr (constexpr auto ep { from.rfind(get_spec<0,1>()) }; ep != std::string_view::npos) { constexpr std::string_view result { from.substr(ep + get_spec<0,1>().size()) }; - if (constexpr auto lc { result.find_first_of(get_spec<1,1>()) }; lc != std::string_view::npos) + if constexpr (constexpr auto lc { result.find_first_of(get_spec<1,1>()) }; lc != std::string_view::npos) return result.substr(0, lc); } return {};