From e237c2b32ec7483db77a6447cde0aa49b52d2d0c Mon Sep 17 00:00:00 2001 From: Marcel Laverdet Date: Sun, 27 Oct 2024 21:39:29 -0500 Subject: [PATCH] Another round of tweaks & cleanups The visit/accept machinery is finally in an ok state.. Now I can start working on the actual project. --- packages/value/enum/accept.cc | 1 - packages/value/struct/accept.cc | 11 +++++------ packages/value/tuple/accept.cc | 5 ----- packages/value/tuple/visit.cc | 1 - 4 files changed, 5 insertions(+), 13 deletions(-) diff --git a/packages/value/enum/accept.cc b/packages/value/enum/accept.cc index 3ac16319..23483e8b 100644 --- a/packages/value/enum/accept.cc +++ b/packages/value/enum/accept.cc @@ -14,7 +14,6 @@ namespace ivm::value { template requires std::is_enum_v struct accept : accept { - using hash_type = uint32_t; using accept::accept; template diff --git a/packages/value/struct/accept.cc b/packages/value/struct/accept.cc index 49c1e194..de9441f7 100644 --- a/packages/value/struct/accept.cc +++ b/packages/value/struct/accept.cc @@ -19,14 +19,12 @@ template struct accept>> { private: template - using accept_setter = accept, std::optional, visit_subject_t>>; + using setter_helper = value_by_key, std::optional, visit_subject_t>; public: - using hash_type = uint32_t; - constexpr accept(const auto_visit auto& visit) : first{visit}, - second{accept_setter{visit}...} {} + second{accept>{visit}...} {} constexpr accept(int /*dummy*/, const auto_visit auto& visit, const auto_accept auto& /*accept_*/) : accept{visit} {} @@ -40,7 +38,8 @@ struct accept>> { util::select_t setter{}; // nb: We `std::forward` the value to *each* setter. This allows the setters to pick an // lvalue object apart member by member if it wants. - auto value = std::get(second)(dictionary_tag{}, std::forward(dictionary), visit); + auto& accept = std::get(second); + auto value = accept(dictionary_tag{}, std::forward(dictionary), visit); if (value) { setter(subject, *std::move(value)); } else if (setter.required) { @@ -54,7 +53,7 @@ struct accept>> { private: accept_next first; - std::tuple...> second; + std::tuple>...> second; }; // Apply `setter_delegate` to each property, filtering properties which do not have a setter. diff --git a/packages/value/tuple/accept.cc b/packages/value/tuple/accept.cc index 612b7dac..cf8a99ed 100644 --- a/packages/value/tuple/accept.cc +++ b/packages/value/tuple/accept.cc @@ -34,11 +34,6 @@ struct accept> { constexpr accept(int /*dummy*/, const auto_visit auto& visit, const auto_accept auto& /*accept*/) : accept{visit} {} - template - constexpr auto operator()(std::integral_constant /*index*/, auto_tag auto tag, auto&& value, auto&&... rest) const -> decltype(auto) { - return std::get(acceptors_)(tag, std::forward(value), std::forward(rest)...); - } - constexpr auto operator()(vector_tag /*tag*/, auto&& value, const auto& visit) const -> std::tuple { auto it = std::begin(value); auto end = std::end(value); diff --git a/packages/value/tuple/visit.cc b/packages/value/tuple/visit.cc index a0c9ef52..1f208c72 100644 --- a/packages/value/tuple/visit.cc +++ b/packages/value/tuple/visit.cc @@ -28,7 +28,6 @@ struct visit> { constexpr visit(int dummy, const auto_visit auto& visit_) : visit_{visit{dummy, visit_}...} {} - // The invoker of visit is expected to invoke `std::get`. This should be fixed. template constexpr auto operator()(std::integral_constant /*index*/, auto&& value, const auto& accept) const -> decltype(auto) { return std::get(visit_)(std::get(std::forward(value)), accept);