Skip to content

Commit

Permalink
Fix compilation issue seen in MSBuild 17.10.4 (#217)
Browse files Browse the repository at this point in the history
  • Loading branch information
leemaguire authored Jun 12, 2024
1 parent 14a4992 commit 70ccfd7
Show file tree
Hide file tree
Showing 8 changed files with 208 additions and 228 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
X.Y.Z Release notes (YYYY-MM-DD)
=============================================================

### Fixed
* Fixed a compilation issue seen in MSBuild 17.10.4 due to usage of `std::apply`.

### Enhancements
* None

### Compatibility
* Fileformat: Generates files with format v24. Reads and automatically upgrade from fileformat v10.

### Internals
* None

----------------------------------------------

2.0.1 Release notes (2024-06-03)
=============================================================

Expand Down
16 changes: 2 additions & 14 deletions include/cpprealm/db.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,7 @@ namespace realm {
m_obj, m_obj.get_table().get_column_key(p.name), m_realm, v.*(std::decay_t<decltype(p)>::ptr)
), ...);
}, managed<T>::schema.ps);
auto m = managed<T>(std::move(m_obj), m_realm);
std::apply([&m](auto && ...ptr) {
std::apply([&](auto&& ...name) {
((m.*ptr).assign(&m.m_obj, &m.m_realm, m.m_obj.get_table().get_column_key(name)), ...);
}, managed<T>::managed_pointers_names);
}, managed<T>::managed_pointers());
return m;
return managed<T>(std::move(m_obj), m_realm);
}
template <typename T>
void remove(T& object)
Expand Down Expand Up @@ -178,13 +172,7 @@ namespace realm {
{
auto object = internal::bridge::resolve<internal::bridge::object>(m_realm, std::move(tsr.m_tsr));
internal::bridge::obj m_obj = object.get_obj();
auto m = managed<T>(std::move(m_obj), m_realm);
std::apply([&m](auto && ...ptr) {
std::apply([&](auto&& ...name) {
((m.*ptr).assign(&m.m_obj, &m.m_realm, m.m_obj.get_table().get_column_key(name)), ...);
}, managed<T>::managed_pointers_names);
}, managed<T>::managed_pointers());
return m;
return managed<T>(std::move(m_obj), m_realm);
}

bool is_frozen() const;
Expand Down
13 changes: 13 additions & 0 deletions include/cpprealm/internal/bridge/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,17 @@ namespace realm::internal::bridge {
};
}

namespace realm::internal {
template <typename... Ts, typename... Us, size_t... Is>
auto constexpr zip_tuples_impl(const std::tuple<Ts...>& tuple1, const std::tuple<Us...>& tuple2, std::index_sequence<Is...>) {
return std::make_tuple(std::make_pair(std::get<Is>(tuple1), std::get<Is>(tuple2))...);
}

template <typename... Ts, typename... Us>
auto constexpr zip_tuples(const std::tuple<Ts...>& tuple1, const std::tuple<Us...>& tuple2) {
static_assert(sizeof...(Ts) == sizeof...(Us), "Tuples must have the same size");
return zip_tuples_impl(tuple1, tuple2, std::index_sequence_for<Ts...>());
}
}

#endif //CPPREALM_BRIDGE_UTILS_HPP
8 changes: 1 addition & 7 deletions include/cpprealm/link.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ namespace realm {
auto assign = [&m, &v](auto& pair) {
(*v).*(std::decay_t<decltype(pair.first)>::ptr) = (m.*(pair.second)).detach();
};
auto zipped = zipTuples(managed<T>::schema.ps, managed<T>::managed_pointers());
auto zipped = internal::zip_tuples(managed<T>::schema.ps, managed<T>::managed_pointers());
std::apply([&v, &m, &assign](auto && ...pair) {
(assign(pair), ...);
}, zipped);
Expand Down Expand Up @@ -139,12 +139,6 @@ namespace realm {
obj, obj.get_table().get_column_key(p.name), realm, (*o).*(std::decay_t<decltype(p)>::ptr)
), ...);
}, managed<T>::schema.ps);
auto m = managed<T>(std::move(obj), *m_realm);
std::apply([&m](auto && ...ptr) {
std::apply([&](auto&& ...name) {
((m.*ptr).assign(&m.m_obj, &m.m_realm, m.m_obj.get_table().get_column_key(name)), ...);
}, managed<T>::managed_pointers_names);
}, managed<T>::managed_pointers());
return *this;
}

Expand Down
371 changes: 172 additions & 199 deletions include/cpprealm/macros.hpp

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion include/cpprealm/managed_dictionary.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ namespace realm {
auto assign = [&m, &v](auto& pair) {
(*v).*(std::decay_t<decltype(pair.first)>::ptr) = (m.*(pair.second)).detach();
};
auto zipped = zipTuples(managed<Type>::schema.ps, managed<Type>::managed_pointers());
auto zipped = internal::zip_tuples(managed<Type>::schema.ps, managed<Type>::managed_pointers());

std::apply([&v, &m, &assign](auto && ...pair) {
(assign(pair), ...);
Expand Down
7 changes: 1 addition & 6 deletions include/cpprealm/managed_list.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ namespace realm {
auto assign = [&m, &v](auto& pair) {
(*v).*(std::decay_t<decltype(pair.first)>::ptr) = (m.*(pair.second)).detach();
};
auto zipped = zipTuples(managed<T>::schema.ps, managed<T>::managed_pointers());
auto zipped = internal::zip_tuples(managed<T>::schema.ps, managed<T>::managed_pointers());
std::apply([&v, &m, &assign](auto && ...pair) {
(assign(pair), ...);
}, zipped);
Expand Down Expand Up @@ -226,11 +226,6 @@ namespace realm {
{
auto list = realm::internal::bridge::list(*m_parent->m_realm, *m_parent->m_obj, m_parent->m_key);
managed<T> m(realm::internal::bridge::get<realm::internal::bridge::obj>(list, m_i), *m_parent->m_realm);
std::apply([&m](auto &&...ptr) {
std::apply([&](auto &&...name) {
((m.*ptr).assign(&m.m_obj, &m.m_realm, m.m_obj.get_table().get_column_key(name)), ...);
}, managed<T>::managed_pointers_names);
}, managed<T>::managed_pointers());
return {std::move(m)};
}

Expand Down
2 changes: 1 addition & 1 deletion include/cpprealm/managed_set.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ namespace realm {
auto assign = [&m, &v](auto& pair) {
(*v).*(std::decay_t<decltype(pair.first)>::ptr) = (m.*(pair.second)).detach();
};
auto zipped = zipTuples(managed<T>::schema.ps, managed<T>::managed_pointers());
auto zipped = internal::zip_tuples(managed<T>::schema.ps, managed<T>::managed_pointers());
std::apply([&v, &m, &assign](auto && ...pair) {
(assign(pair), ...);
}, zipped);
Expand Down

0 comments on commit 70ccfd7

Please sign in to comment.