Skip to content

Commit

Permalink
Fix ttg::persistent
Browse files Browse the repository at this point in the history
We should consider this a hint and fall back to non-persistent
values if the type is not derived from TTValue or we are running
with madness.

Signed-off-by: Joseph Schuchart <[email protected]>
  • Loading branch information
devreal committed Oct 28, 2024
1 parent 8f94781 commit 319cd6b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
5 changes: 5 additions & 0 deletions ttg/ttg/madness/ttvalue.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ namespace ttg_madness {
/* empty */
};

template<typename ValueT>
inline auto persistent(ValueT&& value) {
return std::forward<ValueT>(value);
}

} // namespace ttg_madness

#endif // TTG_MADNESS_TTVALUE_H
8 changes: 5 additions & 3 deletions ttg/ttg/parsec/ttvalue.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,11 @@ namespace ttg_parsec {

template<typename ValueT>
inline auto persistent(ValueT&& value) {
static_assert(std::is_base_of_v<TTValue<std::decay_t<ValueT>>, std::decay_t<ValueT>>,
"ttg::persistent can only be used on types derived from ttg::TTValue");
return detail::persistent_value_ref<ValueT>{value};
if constexpr (std::is_base_of_v<TTValue<std::decay_t<ValueT>>, std::decay_t<ValueT>>) {
return detail::persistent_value_ref<ValueT>{value};
} else {
return std::forward<ValueT>(value);
}
}

} // namespace ttg_parsec
Expand Down

0 comments on commit 319cd6b

Please sign in to comment.