-
Notifications
You must be signed in to change notification settings - Fork 232
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sync to yalanting libs #289
Conversation
iguana/dynamic.hpp
Outdated
std::vector<std::string_view> get_fields_name() const override { | ||
static constexpr auto map = iguana::get_members<T>(); | ||
|
||
std::vector<std::string_view> vec; | ||
for (auto [no, val] : map) { | ||
std::set<std::string_view> sets; | ||
|
||
for (auto const& [no, val] : map) { | ||
std::visit( | ||
[&](auto& field) { | ||
vec.push_back(std::string_view(field.field_name.data(), | ||
field.field_name.size())); | ||
[&](auto const& field) { | ||
if (auto it = sets.emplace(field.field_name.data(), | ||
field.field_name.size()); | ||
it.second) { | ||
vec.push_back(*it.first); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
variant造成重复应该是相邻的吧,直接判断和上一个是否一样就行了,不需要set,可以简化一下!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
有道理,确实可以简化一下。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
有道理,已修改
iguana/dynamic.hpp
Outdated
[&](auto const& field) { | ||
std::string_view const current_name{field.field_name.data(), | ||
field.field_name.size()}; | ||
if (vec.empty() || (!vec.empty() && (vec.back() != current_name))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里可以稍微简化一下,
if (vec.empty() || (vec.back() != current_name))
因为判断vec.back()的时候前面的vec.empty()一定是false,否则为true不会执行vec.back()
No description provided.