Skip to content

Commit

Permalink
Code format adjustment
Browse files Browse the repository at this point in the history
  • Loading branch information
RAVER0306 committed Oct 10, 2024
1 parent fd4208d commit 6918255
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
24 changes: 14 additions & 10 deletions include/ylt/reflection/member_names.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ get_member_names() {
((arr[Is] =
internal::get_member_name<internal::wrap(std::get<Is>(tp))>()),
...);
}(std::make_index_sequence<Count>{});
}
(std::make_index_sequence<Count>{});
#else
init_arr_with_tuple<T>(arr, std::make_index_sequence<Count>{});
#endif
Expand All @@ -154,7 +155,8 @@ inline constexpr auto get_member_names_map() {
return [&]<size_t... Is>(std::index_sequence<Is...>) mutable {
return frozen::unordered_map<frozen::string, size_t, name_arr.size()>{
{name_arr[Is], Is}...};
}(std::make_index_sequence<name_arr.size()>{});
}
(std::make_index_sequence<name_arr.size()>{});
#else
return get_member_names_map_impl(name_arr,
std::make_index_sequence<name_arr.size()>{});
Expand All @@ -175,14 +177,15 @@ inline const auto& get_member_offset_arr(T&& t) {
auto tp = ylt::reflection::object_to_tuple(std::forward<T>(t));

#if __cplusplus >= 202002L
[[maybe_unused]] static std::array<size_t, Count> arr = {
[&]<size_t... Is>(std::index_sequence<Is...>) mutable {
std::array<size_t, Count> arr;
((arr[Is] = size_t((const char*)&std::get<Is>(tp) - (char*)(&t))), ...);
return arr;
}(std::make_index_sequence<Count>{})}; // namespace internal

[[maybe_unused]] static std::array<size_t, Count> arr = {[&]<size_t... Is>(
std::index_sequence<Is...>) mutable {std::array<size_t, Count> arr;
((arr[Is] = size_t((const char*)&std::get<Is>(tp) - (char*)(&t))), ...);
return arr;
}
(std::make_index_sequence<Count>{})
}; // namespace internal

return arr;
#else
[[maybe_unused]] static std::array<size_t, Count> arr =
get_member_offset_arr_impl(t, tp, std::make_index_sequence<Count>{});
Expand Down Expand Up @@ -354,7 +357,8 @@ inline constexpr void for_each(Visit&& func) {
"size_t], at least has std::string_view and make sure keep "
"the order of arguments");
}
}(std::make_index_sequence<arr.size()>{});
}
(std::make_index_sequence<arr.size()>{});
#else
for_each_impl(std::forward<Visit>(func), arr,
std::make_index_sequence<arr.size()>{});
Expand Down
6 changes: 4 additions & 2 deletions include/ylt/reflection/member_value.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,8 @@ inline constexpr void for_each(T&& t, Visit&& func) {
[&]<size_t... Is>(std::index_sequence<Is...>) mutable {
constexpr auto arr = get_member_names<T>();
(func(args, arr[Is]), ...);
}(std::make_index_sequence<sizeof...(args)>{});
}
(std::make_index_sequence<sizeof...(args)>{});
#else
visit_members_impl0<T>(std::forward<Visit>(func), std::make_index_sequence<sizeof...(args)>{}, args...);
#endif
Expand All @@ -232,7 +233,8 @@ inline constexpr void for_each(T&& t, Visit&& func) {
[&]<size_t... Is>(std::index_sequence<Is...>) mutable {
constexpr auto arr = get_member_names<T>();
(func(args, arr[Is], Is), ...);
}(std::make_index_sequence<sizeof...(args)>{});
}
(std::make_index_sequence<sizeof...(args)>{});
#else
visit_members_impl<T>(std::forward<Visit>(func), std::make_index_sequence<sizeof...(args)>{}, args...);
#endif
Expand Down

0 comments on commit 6918255

Please sign in to comment.