Skip to content

Commit

Permalink
pre-v1.0g-update
Browse files Browse the repository at this point in the history
  • Loading branch information
dakka committed Apr 5, 2024
1 parent 715848d commit 6ea17a9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
12 changes: 6 additions & 6 deletions examples/example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<typename T>
Expand Down Expand Up @@ -136,8 +136,8 @@ int main(void)
enum_bitset<numbers> c(15);
std::cout << c << '\n';
#if __has_include(<format>)
for(const auto [a, b] : conjure_enum<component>::scoped_entries)
std::cout << std::format("{:9} {}\n", a, b);
for(const auto [a2, b2] : conjure_enum<component>::scoped_entries)
std::cout << std::format("{:9} {}\n", a2, b2);
for(const auto [value, str] : conjure_enum<component>::entries) // scoped
std::cout << std::format("{:<2} {}\n", static_cast<int>(value), str);
for(const auto [value, str] : conjure_enum<component>::sorted_entries) // scoped
Expand Down
4 changes: 2 additions & 2 deletions examples/unittests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 };

//-----------------------------------------------------------------------------------------
Expand Down
8 changes: 4 additions & 4 deletions include/fix8/conjure_enum.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class fixed_string final
constexpr fixed_string(std::string_view sv, std::integer_sequence<char, C...>) noexcept : _buff{sv[C]..., 0} {}

public:
constexpr fixed_string(std::string_view sv) noexcept : fixed_string{sv.data(), std::make_integer_sequence<char, N>{}} {}
explicit constexpr fixed_string(std::string_view sv) noexcept : fixed_string{sv.data(), std::make_integer_sequence<char, N>{}} {}
constexpr fixed_string() = delete;
constexpr std::string_view get() const noexcept { return { _buff.data(), N }; }
constexpr operator std::string_view() const noexcept { return get(); }
Expand Down Expand Up @@ -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 {};
Expand Down Expand Up @@ -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 {};
Expand Down

0 comments on commit 6ea17a9

Please sign in to comment.