补全边角

This commit is contained in:
2026-08-08 21:21:23 +08:00
parent a6d6f8c6d3
commit c51c9d2937
24 changed files with 359 additions and 56 deletions
+13 -8
View File
@@ -24,7 +24,7 @@ consteval std::string_view declared_property_key() {
}
template <class... Properties>
consteval bool unique_property_keys() {
constexpr std::array keys{declared_property_key<Properties>()...};
constexpr std::array<std::string_view, sizeof...(Properties)> keys{declared_property_key<Properties>()...};
for (std::size_t i = 0; i < keys.size(); ++i) {
for (std::size_t j = i + 1; j < keys.size(); ++j) {
if (keys[i] == keys[j]) {
@@ -374,19 +374,24 @@ Synchronization_Plan materialize_synchronization_plan(Source&& source) {
}
}
template <Valid_Property_Schema Schema, class Function>
bool visit_schema_property(const Schema& schema, std::string_view key_value, Function&& function) {
bool visit_schema_property_at(const Schema& schema, std::size_t index_value, Function&& function) {
bool found = false;
schema.for_each_property([&](auto index, const auto& descriptor) {
if (!found) {
using property_type = std::remove_cvref_t<decltype(descriptor)>;
if (declared_property_key<property_type>() == key_value) {
std::invoke(function, index, descriptor);
found = true;
}
if (!found && decltype(index)::value == index_value) {
std::invoke(function, index, descriptor);
found = true;
}
});
return found;
}
template <Valid_Property_Schema Schema, class Function>
bool visit_schema_property(const Schema& schema, std::string_view key_value, Function&& function) {
auto index = schema_property_index<Schema>(key_value);
if (!index) {
return false;
}
return visit_schema_property_at(schema, *index, std::forward<Function>(function));
}
template <class Object, class Defaults, class Source, class... Properties>
auto make_object_schema(Defaults&& object_defaults, Source&& synchronization_source, Properties&&... properties) requires Synchronization_Source_Type<std::remove_cvref_t<Source>> {
using schema_type = Object_Schema<Object, std::decay_t<Defaults>, std::decay_t<Properties>...>;